Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseQueryAdapter Error When Local Datastore and CachePolicy Enabled #123

Open
ayublin opened this issue Jan 20, 2016 · 1 comment
Open
Labels

Comments

@ayublin
Copy link

ayublin commented Jan 20, 2016

Hello, I am getting a fatal error when enabling local datastore:

    Parse.enableLocalDatastore(this);
    Parse.initialize(this);

And setting cache policy on my ParseQuery object under ParseQueryAdapter:

    public ServerAdapter(Context context) {
        super(context, new QueryFactory() {
            @Override
            public ParseQuery create() {
                ParseQuery query = new ParseQuery("Server");
                query.setCachePolicy(ParseQuery.CachePolicy.CACHE_ELSE_NETWORK);
                return query;
            }
        });
    }

Are they not supposed to be enabled together? I can't think of any reason why they shouldn't though.

Here is the error message:

Caused by: java.lang.IllegalStateException: Unsupported method when Local Datastore is enabled.
  at com.parse.ParseQuery.throwIfLDSEnabled(ParseQuery.java:291)
  at com.parse.ParseQuery.throwIfLDSEnabled(ParseQuery.java:277)
  at com.parse.ParseQuery.access$000(ParseQuery.java:89)
  at com.parse.ParseQuery$State$Builder.setCachePolicy(ParseQuery.java:665)
  at com.parse.ParseQuery.setCachePolicy(ParseQuery.java:1013)
  at com.package.myapp.views.adapters.ServerAdapter$1.create(ServerAdapter.java:20)
  at com.parse.ParseQueryAdapter.loadObjects(ParseQueryAdapter.java:366)
  at com.parse.ParseQueryAdapter.loadObjects(ParseQueryAdapter.java:362)
  at com.parse.ParseQueryAdapter.registerDataSetObserver(ParseQueryAdapter.java:326)
  at android.widget.ListView.setAdapter(ListView.java:468)
  at com.package.myapp.MainActivity.onCreate(MainActivity.java:44)
  at android.app.Activity.performCreate(Activity.java:5133)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2225)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2311) 
  at android.app.ActivityThread.access$600(ActivityThread.java:149) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293) 
  at android.os.Handler.dispatchMessage(Handler.java:99) 
  at android.os.Looper.loop(Looper.java:137) 
  at android.app.ActivityThread.main(ActivityThread.java:5214) 
  at java.lang.reflect.Method.invokeNative(Native Method) 

The issue is similar to this SO thread: http://stackoverflow.com/q/32438838

@grantland
Copy link
Contributor

You're correct, LDS and cache policies are not compatible with each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants