I am very new to android. I want to send data(location coordinates) from sql lite database to the server when connection is on.If the connection is off I have to store them in database. Do I need to have service on the background that sends the data to server when connection is on?
Asked
Active
Viewed 154 times
-2
-
you don't have to, but you may. All depends on your choice. What is the question? – Vladyslav Matviienko Apr 21 '17 at 12:21
-
So the real question is how to detect if you're connected to the internet and when not? There are plenty of tutorials for this on SO an on other sites. [Check for internet connection](http://stackoverflow.com/questions/1560788/how-to-check-internet-access-on-android-inetaddress-never-times-out) and [the event for internet connection](http://stackoverflow.com/questions/3767591/check-intent-internet-connection) – Denny Apr 21 '17 at 12:22
-
question is that Do I need the service on the background or not? – Developer Apr 21 '17 at 12:24
-
It depends on your needs. – Denny Apr 21 '17 at 12:26
1 Answers
0
While submitting the form data check if internet is connected if yes send your data to server and if no save it in your database. You need a broadcast receiver which will inform your when internet connection is connected, if connected call a service which will send data to the server and once send delete that data from database.

Satyam Anand
- 377
- 1
- 8
-
Thanks for telling the steps for it, do you mind adding some reference links on how to do these steps. This would help the OP. – Denny Apr 21 '17 at 12:24
-