2

In android i am using Parse and back4app.com for my back-end, whenever i use myParseobject.saveInBackground() in the return Save Callback i am getting error message that ParseException : only ACLs can be stored in the ACL key If anyone have idea about this please share.

varotariya vajsi
  • 3,965
  • 37
  • 39

2 Answers2

5

Whenever you save your ParseObject using saveInBackground() method, you need to do YourParseObject.setAcl(your_Acl_Object_here); You can find working code from below,

For public access you can write as,

ParseUser currentUser = ParseUser.getCurrentUser();
ParseACL acl = new ParseACL(currentUser);
acl.setPublicReadAccess(true);
YourParseObject.setACL(acl);

If you want to use only for CurrentUser access you can write as,

ParseUser currentUser = ParseUser.getCurrentUser();
ParseACL acl = new ParseACL();
acl.setReadAccess(currentUser,true);
acl.setWriteAccess(currentUser,true);
YourParseObject.setACL(acl);
varotariya vajsi
  • 3,965
  • 37
  • 39
2

To avoid this error, I set ACLs for currentUser after its login. Surprisingly, it does help and I don't see any errors on that session when saving objects.

// default ACLs for User object
ParseACL parseACL = new ParseACL(ParseUser.getCurrentUser());
parseACL.setPublicReadAccess(true);

ParseUser.getCurrentUser().setACL(parseACL);
Aurintas
  • 205
  • 3
  • 11