-5

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?

Rajen Raiyarela
  • 5,526
  • 4
  • 21
  • 41
RubyDigger19
  • 835
  • 13
  • 38

3 Answers3

2

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.

toantran
  • 1,789
  • 17
  • 25
  • This is a borderline [link-only answer](http://meta.stackexchange.com/q/8231/213671). You should expand your answer to include as much information here, and use the link only for reference. – Tobi Nary Mar 15 '16 at 14:48
  • Please don't post answers on obviously off topic / bad questions! [See: **Should one advise on off topic questions?**](http://meta.stackoverflow.com/q/276572/1768232) – Tobi Nary Mar 15 '16 at 14:50
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/11634329) – Tobi Nary Mar 15 '16 at 14:50
  • thanks for reminding @SmokeDispenser – toantran Mar 16 '16 at 03:08
2

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.

Community
  • 1
  • 1
K Neeraj Lal
  • 6,768
  • 3
  • 24
  • 33
1

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.

Mukul Tripathi
  • 275
  • 1
  • 2
  • 10