Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9266411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:18:44+00:00 2026-06-18T14:18:44+00:00

With this code I send information from my local sqlite database to my server(mysql)

  • 0

With this code I send information from my local sqlite database to my server(mysql) and it works fine. But I only send data from the table1. If I want to send the data of all my sqlite tables to my server how I can do that?

public class sendInformation  {
public SQLiteDatabase newDB;
JSONObject jObject;
JSONArray jArray = new JSONArray();

public void getValues()
{
    try
    {
        newDB = SQLiteDatabase.openDatabase("/data/data/com..../databases/...db",null,SQLiteDatabase.CONFLICT_NONE);    
    }catch(SQLException e)
    {
        Log.d("Error","Error while Opening Database");
        e.printStackTrace();
    }
    try
    {
        Cursor c = newDB.rawQuery("Select * from table1",null);
        if (c.getCount()==0) 
        {
            c.close();
            Log.d("","no items on the table");              
        }else
        {
            c.moveToFirst();    

            while(c.moveToNext()) {
                jObject = new JSONObject();
                jObject.put("ID", c.getString(c.getColumnIndex("ID")));
                jObject.put("Notes", c.getString(c.getColumnIndex("Notes")));
                jObject.put("Cellphone", c.getString(c.getColumnIndex("Cellphone")));
                jObject.put("Date", "null");
                jObject.put("Address", "null");
                jArray.put(jObject);
            }

            c.close();
            Log.d("","ALL the data in the DB"+jArray.toString());
            int arrayLength=jArray.length();
            Log.d("","Lenght of the jArray"+arrayLength);
            HttpParams httpParams = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParams,9000);
            HttpConnectionParams.setSoTimeout(httpParams, 9000);

            HttpClient client = new DefaultHttpClient(httpParams);

            String url = "http://ipaddress/..../test.php?arrayLength="+arrayLength;

            HttpPost request = new HttpPost(url);
            request.setEntity(new ByteArrayEntity(jArray.toString().getBytes("UTF8")));      
            request.setHeader("json", jArray.toString());

            HttpResponse response = client.execute(request);
            HttpEntity entity = response.getEntity();
            // If the response does not enclose an entity, there is no need

            if (entity != null) {
                InputStream instream = entity.getContent();

                String result =  RestClient.convertStreamToString(instream);
                Log.i("Read from server", result); 
            }
        }       
    } catch (UnsupportedEncodingException uee) {
        Log.d("Exceptions", "UnsupportedEncodingException");
        uee.printStackTrace();
    }catch (Throwable t) {
        Log.d("","request fail"+t.toString());
    }

    this.newDB.close(); 
  }
}

As you can see, I get all the data from table1 and I create a jsonObject.

  • I pass that to the test.php file, but if I make another query from table2,table3…, I have to put the values of the second and third table in the same JsonObject?
  • If I do that, how will I know which data is from which table?
  • If I can send multiples jsonobject, how do I do that and how will I receive that data in my test.php file.

Right now I do it with $json = file_get_contents('php://input');

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:18:45+00:00Added an answer on June 18, 2026 at 2:18 pm

    You already have half the solution. Just replicate the code that creates and populates a JsonObject for each additional table, and add those to your JsonArray. Instead of a JsonArray you can use another JsonObject – it can contain other JsonObjects.

    On the server, just use json_decode($json, true) and you will get your data as an array of arrays – dump the result to a file with print_r() so you can see the structure of the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this php code to send the users information from the contact form
i made this code so i can send information to my website. Only now
I want to send an SMS via intent, but when I use this code,
this is what is my java code to send mail but when i send
i'm trying to get information from a remote server on my local machine. readyState
I am getting this error when I try to send via the local server
This code will submit the information from the form to a php file, everything
I want to use wp_remote_post to send information from one server to my other
I need to connect and send/receive information from an MS SQL server in my
I am using this code to send mail with php http://www.siteduzero.com/tutoriel-3-35146-e-mail-envoyer-un-e-mail-en-php.html#ss_part_4 . This code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.