Trying to connect Android app with SQLite to SQL Db via webservice (php) -


to clarify on problem; i'm following old tutorial try , learn basic sync functionality android app (here). have php webservice in place, believe permissions set right, post in android code set correct server ip. when try synch app sql getting asynchttpclient statuscode of 0. far can tell, means request timing out?

if i'm looking how extend timeout limit, if not stuck , appreciate input idea of i'm going wrong. code below relevant part android studio.

public void syncsqlitemysqldb(){     //create asychttpclient object     asynchttpclient client = new asynchttpclient();     requestparams params = new requestparams();     arraylist<hashmap<string, string>> userlist =  controller.getallusers();     if(userlist.size()!=0){         if(controller.dbsynccount() != 0){             prgdialog.show();             params.put("usersjson", controller.composejsonfromsqlite());             client.post("http://46.105.118.169:9000/sqlitemysqlsync/insertuser.php",params ,new asynchttpresponsehandler() {                 @override                 public void onsuccess(string response) {                     system.out.println(response);                     prgdialog.hide();                     try {                         jsonarray arr = new jsonarray(response);                         system.out.println(arr.length());                         for(int i=0; i<arr.length();i++){                             jsonobject obj = (jsonobject)arr.get(i);                             system.out.println(obj.get("id"));                             system.out.println(obj.get("status"));                             controller.updatesyncstatus(obj.get("id").tostring(),obj.get("status").tostring());                         }                         toast.maketext(getapplicationcontext(), "db sync completed!", toast.length_long).show();                     } catch (jsonexception e) {                         // todo auto-generated catch block                         toast.maketext(getapplicationcontext(), "error occured [server's json response might invalid]!", toast.length_long).show();                         e.printstacktrace();                     }                 }                  @override                 public void onfailure(int statuscode, throwable error,                                       string content) {                     // todo auto-generated method stub                     prgdialog.hide();                     if(statuscode == 404){                         toast.maketext(getapplicationcontext(), "requested resource not found", toast.length_long).show();                     }else if(statuscode == 500){                         toast.maketext(getapplicationcontext(), "something went wrong @ server end", toast.length_long).show();                     }else{                         toast.maketext(getapplicationcontext(), "error: " + statuscode, toast.length_long).show();                      }                 }             });         }else{             toast.maketext(getapplicationcontext(), "sqlite , remote mysql dbs in sync!", toast.length_long).show();         }     }else{         toast.maketext(getapplicationcontext(), "no data in sqlite db, please enter user name perform sync action", toast.length_long).show();     } 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -