can anyone please help me? I am trying to enable Parse Local Datastore in a fragment but its throwing out an error: java.lang.IllegalStateException: Parse#enableLocalDatastore(Context)
must be invoked before Parse#initialize(Context, String, String)
. Below is the code I use which works perfectly fine in an Activity but not in Fragment and I know the getActivity context is not null since the second line works.
Parse.enableLocalDatastore(getActivity());
Parse.initialize(getActivity(), DeveloperKey.ParseAppID, DeveloperKey.ParseClientKey);
I realised using pin()
automatically saves to the local datastore so there was no need to explicitly use enableLocaldatastore()
. With this, I can query from localdatastore
and get the cached result.