I am developing an Android application, and I am making many RESTful requests to a server for information. Should I always make these requests, or store some of it in a SQLite database on the device? If I should store, how do I determine how much (if not all) of the data should be stored?
The app is something of an educational social network, so there are objects such as:
- Users
- Schools
- Notes
- Courses
- Comments
- Question
Currently the plan is to store the information in the database and check for updates frequently, or should I always request the data from the server? Additionally, should I pull nested data in a single request or split it up into multiple RESTful requests?
The best solution would be to store all the data you have locally, and just sometimes fire up
AsyncTaskorAsyncLoaderto download the updates. This way your users will be able to use your application when offline and don’t need to wait for download to finish when your application starts.You should always have some data to show. It might be useful to include a basic data set along with your application, so the database gets populated on the first run even when there’s no network.
single request is generally faster than several smaller requests, however, it has higher probability of failing on mobile networks. if your data requests don’t take more than 10sec on GSM network, you should be fine, otherwise you might consider splitting into smaller requests.