Click here to Skip to main content
Rate this: bad
good
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
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 120
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 5 Apr 2013
Copyright © CodeProject, 1999-2014
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