I have an offline app with lot of data. I need to convert the sqlite data to JSON and send it to web server.
I would like to know what is the best way to do that?
I have an offline app with lot of data. I need to convert the sqlite data to JSON and send it to web server.
I would like to know what is the best way to do that?
Use jackson or gson. Construct POJO object and use these libs to convert to json https://github.com/FasterXML/jackson
Should be straight to work on.
You need a BroadCastReciever
that triggers when you get internet connectivity. Check this SO thread for more info.
Make a Service
class that makes a webservice call to your website. I recommend using retrofit or volley library to make the webservice call. Here is the official guide to using retrofit.
Then use jackson/gson to convert your objects to json. See @autobot_101's answer on how to do that.
Pass this json data as a parameter to your webservice call. See this SO thread for more info.
Link only answers are not good but I think this should give you an idea of how to approach the problem.
Use Jackson API. You have to define a pojo, some annotations, and within no time you will have it running. Google Jackson API tutorials. Also there are some xml/json to pojo free online converters.
Lemme know if Google doesn't help you and I can write something quick for you.