Click here to Skip to main content
12,067,278 members (53,774 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Mobile
i want to save my mobile data like contectid,firstname,lastname,mobile no,emails which is stored in SQlite database,into the Mysql data base using jsp than please send me solution.......
Posted 25-Mar-13 22:24pm
Edited 25-Mar-13 22:34pm
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

package com.example.upload;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Scanner;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.util.Base64;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {

InputStream is;

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.activity_main);


ArrayList nameValuePairs = new

ArrayList();

nameValuePairs.add(new BasicNameValuePair("Name","My Name"));

nameValuePairs.add(new BasicNameValuePair("Age","23"));
..............
...............
...........

try{

HttpClient httpclient = new DefaultHttpClient();

HttpPost httppost = new

HttpPost("http://.............your php file url ");

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

HttpResponse response = httpclient.execute(httppost);

HttpEntity entity = response.getEntity();

is = entity.getContent();

}catch(Exception e){

Log.e("log_tag", "Error in http connection "+e.toString());

}


..........Here write the android code to inset data into SQLite database.........
..................
..............
..........
}
}

And in php by the help of this php code we can get it


$name=$_REQUEST['name'];
$age=$_REQUEST['age'];

now using database command you can easily insert it in to mysql database
...........
.............
........
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160208.1 | Last Updated 5 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100