xml - which is the best practice to store location data on android device -
i had built android app tracks vehicle location (android device).my app updates locations , speed server @ every t seconds, using mobile data.app monitors vehicle speed under speed limit or not.definitely app not able contact server if data connectivity lost. @ point best practice store location data in device.
my plan store datas in xml file , update server later.since app wont update each , every locations after 19 secs or greater, think simplest option.please guide me in right path, if im wrong. , dont know how update bunch of data xml server.
my current location saving strategy is: calling php page(asynctask) on server passing location , other relevent datas. how implement if have bunch of datas!
you can store data in format: sqlite or text file xml/json/csv. store in sqlite. reason following. can create 2 parallel tasks, 1 of collects data sqlite database , other sends bunches of data server asynchronously when it's possible. sqlite more convenient organize text files, since work records.
about sending bunches of data server. can send data json inside body of http post request. on server should read data , save server database in 1 sql statement. possible, it's called batch insert statement.
this example of sending json data in body of http post request:
httppost httppost = new httppost(urlstring); string bodyjsonstring = this.getbodyjsonstring(); httppost.setentity(new stringentity(bodyjsonstring, http.utf_8)); @override string getbodyjsonstring() { jsonobject jsonobject = new jsonobject(); try { jsonobject.put("text", this.message); jsonobject.put("theme", this.theme); } catch (jsonexception e) { e.printstacktrace(); } string resultstring = jsonobject.tostring(); log.v(helper.tag, "resultstring = " + resultstring); return resultstring; }
Comments
Post a Comment