Click here to Skip to main content
14,267,453 members
   

Android

 
QuestionImage Transfer from Raspberry Pi (in Python) to Android app (Java) Pin
Member 1453729921-Jul-19 19:57
memberMember 1453729921-Jul-19 19:57 
AnswerRe: Image Transfer from Raspberry Pi (in Python) to Android app (Java) Pin
Richard MacCutchan21-Jul-19 21:29
protectorRichard MacCutchan21-Jul-19 21:29 
Questionpython Pin
Member 1453431517-Jul-19 23:25
memberMember 1453431517-Jul-19 23:25 
AnswerRe: python Pin
Richard MacCutchan18-Jul-19 0:37
protectorRichard MacCutchan18-Jul-19 0:37 
AnswerRe: python Pin
Afzaal Ahmad Zeeshan18-Jul-19 0:56
mveAfzaal Ahmad Zeeshan18-Jul-19 0:56 
QuestionQR camera scan with android phone using C# Pin
A.Shoman15-Jul-19 21:04
memberA.Shoman15-Jul-19 21:04 
AnswerRe: QR camera scan with android phone using C# Pin
Richard MacCutchan15-Jul-19 21:15
protectorRichard MacCutchan15-Jul-19 21:15 
QuestionMessage Closed Pin
5-Jul-19 1:29
memberlucaxhenderson5-Jul-19 1:29 
Questiondownload sound file in android webview Pin
Member 1450174330-Jun-19 23:00
memberMember 1450174330-Jun-19 23:00 
QuestionRe: download sound file in android webview Pin
David Crow3-Jul-19 4:11
memberDavid Crow3-Jul-19 4:11 
AnswerRe: download sound file in android webview Pin
Member 145017433-Jul-19 4:27
memberMember 145017433-Jul-19 4:27 
QuestionCan't make charge with stripe in android Fire base Pin
Saboor880220-Jun-19 6:21
memberSaboor880220-Jun-19 6:21 
SuggestionRe: Can't make charge with stripe in android Fire base Pin
David Crow21-Jun-19 3:08
memberDavid Crow21-Jun-19 3:08 
QuestionAll record from SQLite DB is not inserting properly by using PHP and Android. Loop is not working. Pin
PRASANTA KUMAR BISWAS5-May-19 19:33
memberPRASANTA KUMAR BISWAS5-May-19 19:33 
--Android Code
--============

<pre>private class UploadData extends AsyncTask<String, Void, String>
    {
        @Override
        protected void onPreExecute()
        {
            progressDialog.setMessage("Wait !!! Transferring SQLite Data into SQL Server DB.");
            progressDialog.setIndeterminate(false);
            progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            progressDialog.setCancelable(false);
            progressDialog.show();
        }

        @Override
        protected void onPostExecute(String result)
        {
            progressDialog.dismiss();

            AlertDialog YesNo1 = DialogYesNo();
            YesNo1.setMessage("Hh Count Tablet: " + HhTablet + " , Hh Count Server: " + HhServer + "\n" + " -- has been transferred to SQL server DB !!! ");
            YesNo1.setCancelable(false);
            YesNo1.show();

            HhServer = 0;
        }

        @Override
        protected String doInBackground(String... params)
        {
            String result = "";
            httpclient = new DefaultHttpClient();
            httppost = new HttpPost("http://172.16.15.13/testing/datasync.php"); // make sure the url is correct.

            try
            {
                try
                {
                    cursor = ConnectionDB.SelectRecord("Select HH,PartM,GISID,Mohalla from HH");
                    HhTablet = cursor.getCount();

                    if (cursor != null)
                    {
                        cursor.moveToFirst();

                        while (!cursor.isAfterLast())
                        {
                            for (int k = 0; k < HhTablet; k++)
                            {
                                //Add data
                                //========
                                nameValuePairs = new ArrayList<NameValuePair>(4);

                                // Always use the same variable name for posting i.e the android side variable name and php side variable name should be similar
                                //==============================================================================================================================
                                nameValuePairs.add(new BasicNameValuePair("HH", cursor.getString(cursor.getColumnIndex("HH"))));
                                nameValuePairs.add(new BasicNameValuePair("PartM", cursor.getString(cursor.getColumnIndex("PartM"))));
                                nameValuePairs.add(new BasicNameValuePair("GISID", cursor.getString(cursor.getColumnIndex("GISID"))));
                                nameValuePairs.add(new BasicNameValuePair("Mohalla", cursor.getString(cursor.getColumnIndex("Mohalla"))));
                                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                                HhServer = HhServer + 1;
                            }

                            //Execute HTTP Post Request
                            //=========================
                            ResponseHandler<String> responseHandler = new BasicResponseHandler();
                            String responseBody = httpclient.execute(httppost, responseHandler);

                            // JSON Parse
                            //============
                            JSONObject json = new JSONObject(responseBody);
                            JSONArray jArray = json.getJSONArray("posts");
                            ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

                            for (int i = 0; i < jArray.length(); i++)
                            {
                                HashMap<String, String> map = new HashMap<String, String>();
                                JSONObject e = jArray.getJSONObject(i);
                                String s = e.getString("post");
                                JSONObject jObject = new JSONObject(s);

                                map.put("HH", jObject.getString(cursor.getString(cursor.getColumnIndex("HH"))));
                                map.put("PartM", jObject.getString(cursor.getString(cursor.getColumnIndex("PartM"))));
                                map.put("GISID", jObject.getString(cursor.getString(cursor.getColumnIndex("GISID"))));
                                map.put("Mohalla", jObject.getString(cursor.getString(cursor.getColumnIndex("Mohalla"))));
                                mylist.add(map);
                                cursor.moveToNext();
                            }
                        }
                    }
}
                catch (Exception ex)
                {
                    ex.printStackTrace();
                }
                finally
                {
                    cursor.close();
                }
}
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
            return result;
        }
    }


--PHP code
--==========

<?php
include ("dbconnection.php"); 

$json = file_get_contents('php://input');
$obj = json_decode($json);

$HH=$_POST[HH];
$PartM=$_POST[PartM];
$GISID=$_POST[GISID];
$Mohalla=$_POST[Mohalla];

//First need to delete from database by TABID
//===========================================
//$recdel = "DELETE From HH"; 
//$stmtdel = $conn->query( $recdel );  
//===========================================

//Then need to insert
//===================

//$recdel = "SELECT COUNT(*) FROM HH"; 
//$stmtdel = $conn->query( $recdel ); 

//if ($stmtdel > 0) 
//{
	//$query = "UPDATE HH SET `HH` = '$HH',`PartM` = '$PartM',`GISID` = '$GISID',`Mohalla` = '$Mohalla' WHERE `HH` = '$HH'";   
	//$stmt = $conn->query( $query );
//}
//else
//{
	$query = "INSERT INTO HH(HH,PartM,GISID,Mohalla) VALUES ('$HH','$PartM','$GISID','$Mohalla')";   
	$stmt = $conn->query( $query );
//}
	
	if ($query) 
	{
        $response["success"] = 1;
        $response["message"] = "Record is successfully created.";
        echo json_encode($response);
    } 
	else 
	{
        $response["success"] = 0;
        $response["message"] = "Sorry! An error occurred.";
        echo json_encode($response);
    }
	$posts = array(1);
    header('Content-type: application/json');
    echo json_encode(array('posts'=>$posts));
	
$stmt = null;   
$conn = null; 
?>


modified 6-May-19 6:12am.

SuggestionRe: I am unable to send SQLite data(multiple record) to SQL server 2005 database by using PHP and Android Pin
Richard MacCutchan5-May-19 21:55
protectorRichard MacCutchan5-May-19 21:55 
GeneralRe: I am unable to send SQLite data(multiple record) to SQL server 2005 database by using PHP and Android Pin
PRASANTA KUMAR BISWAS5-May-19 23:41
memberPRASANTA KUMAR BISWAS5-May-19 23:41 
GeneralRe: I am unable to send SQLite data(multiple record) to SQL server 2005 database by using PHP and Android Pin
Richard MacCutchan5-May-19 23:51
protectorRichard MacCutchan5-May-19 23:51 
SuggestionRe: All record from SQLite DB is not inserting properly by using PHP and Android. Loop is not working. Pin
Richard Deeming8-May-19 1:34
mveRichard Deeming8-May-19 1:34 
Questionno database data after depolyment Pin
Wiep Corbier29-Apr-19 21:54
memberWiep Corbier29-Apr-19 21:54 
AnswerRe: no database data after depolyment Pin
Richard MacCutchan29-Apr-19 22:43
protectorRichard MacCutchan29-Apr-19 22:43 
GeneralRe: no database data after depolyment Pin
Wiep Corbier29-Apr-19 23:16
memberWiep Corbier29-Apr-19 23:16 
GeneralRe: no database data after depolyment Pin
Wiep Corbier30-Apr-19 7:29
memberWiep Corbier30-Apr-19 7:29 
GeneralRe: no database data after depolyment Pin
Mycroft Holmes30-Apr-19 12:31
memberMycroft Holmes30-Apr-19 12:31 
GeneralRe: no database data after depolyment Pin
Wiep Corbier1-May-19 8:10
memberWiep Corbier1-May-19 8:10 
AnswerMessage Closed Pin
18-Jun-19 20:02
memberMember 1450266718-Jun-19 20:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.