I am in process of making one app on Android
. The application will continuously update the online database
. The data will be in the form of double
and string
. What are the best way to get this function. I worked on mongoDB
. Can i use it or please tell me some other options.

- 1
- 1

- 1,031
- 10
- 26
-
Do you need to pull the data in background (even if your app is not "opened" and the android device is sleeping)? – KishuDroid Sep 23 '15 at 12:05
-
No. the user need to `check the checkbox` and only then the database can be updated. – Saad Saadi Sep 23 '15 at 12:07
4 Answers
From an application point of view, it's not good to continuously ping the server, as it consumes a lot of battery, and let's assume your app updates the server every five seconds, what will you do if your app misses one or two update calls. You will have to write a mechanism to recover the missed update calls. So a better solution will be to save the data in a text file or in an sqlite database. Then use a SyncAdapter to automatically Sync data or to update data on the server from the text file or local database. The SyncAdapter uses Accounts and makes sure that if you miss a sync, it is later executed. You don't have to write the code to recover from missed update calls.

- 4,622
- 2
- 18
- 33
-
Got it. Let's change the scenario, data will be updated only when the user press a specific button. What will be your suggestion in that case. User will press a button only when a specific device will be connected with the device via usb or Bluetooth. – Saad Saadi Sep 23 '15 at 12:26
-
In that case, i would say to keep the data in the text file, and make your app listen for events of device disconnection. Once the device disconnects then just upload the whole text file to the server, and make your server read the text file line by line and update the database. – Eric B. Sep 23 '15 at 12:43
Mongo DB Supports Multiple Platforms But it aint Entered Android platform yet You need to create a WebService and Use it to Access data from MongoDB and Use it in your Solution
Reference : MongoDB on Android
or
I Suggest you to Use Parse Cloud Database,as it provides SDK for All mobile Environments like Android and IOS for easy implementation and also it recently Launched a Javascript SDK to use.Its free for Trial.
Check it out Here: https://www.parse.com/

- 1
- 1

- 12,627
- 3
- 25
- 37
You need to create Web services to hit database on servers.
for this you can use your own server or Parse.com APIs.

- 1,977
- 2
- 18
- 32
Its easy, call webservice which made for posting or getting data in online database.
For calling web service use async task.
Below link help you to code webservice http://www.javatpoint.com/android-web-service

- 5,411
- 4
- 30
- 47