I am using parse for chat application in android for storing the data I am using both the server and local database(Parse.enableLocalDatastore()) it is working fine, the problem is with fetching data from the database like if network is not available the data will return from local database and if it is available it will return directly from parse so how can i differentiate between them? should i use query.fromLocalDatastore() method while quering the data or not?
Asked
Active
Viewed 615 times
1 Answers
1
You're going to have to build 2 different queries, one for local data and one for network data, and then figure out which one you want to display on screen.
There are a few scenarios you have to account for :
- Server side deletion, addition and update
- Client side deletion, addition and update
Not all of these need to be accounted for, only those that make sense for your application.
Keep in mind that when an object is pinned (and not saved to the server), it does not have an objectId
, but it does have something called a localId
(it's private api but you can see it in the debugger). You can check for the existence of objectId
to determine if the object was created locally and has never been saved to the server.

hhanesand
- 990
- 11
- 28