Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 25-Mar-13 21:34pm
v3

1 solution

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<namevaluepair> nameValuePairs = new

ArrayList<namevaluepair>();

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.........
..................
..............
..........
}
}
Java


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
...........
.............
........
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900