android - Why do I receive the "ParseObject has no data for this key" error when pinning to localDatastore? -
using following query want list of parseusers containing subset of columns, defined querycolumns list. receive results, when try pin them local datastore receive exception:
com.parse.parseexception: java.lang.illegalstateexception: parseobject has no data key. call fetchifneeded() data.
i can't understand why... should message appear when "complex" columns parseobjects involved? data i'm querying is, instead, composed strings , booleans only.
final list<string> querycolumns = arrays.aslist( "username", // string "email", // string "avatarcountry", // string "avatarid", // string "showcountry" // boolean "facebookid" // string ); parsequery<parseuser> query = parseuser.getquery(); query.selectkeys(querycolumns); query.wherecontainedin("facebookid", fids); query.findinbackground(new findcallback<parseuser>() { @override public void done(list<parseuser> result, parseexception ex) { if (ex == null) { // stuff... pin results parseuser.pinallinbackground(cached_players_label, result, new savecallback() { @override public void done(parseexception pinex) { // exception here: java.lang.illegalstateexception: parseobject has no data key. call fetchifneeded() data. } }); } } });
your exception's containing answer: call fetchifneeded() data.
change code following:
query.findinbackground(new findcallback<parseuser>() { @override public void done(list<parseuser> result, parseexception e) { parseobject.fetchallifneededinbackground(result, new findcallback<parseuser>() { @override public void done(list<parseuser> list, parseexception ex) { if (ex == null) { parseobject.pinallinbackground(cached_players_label, result, new savecallback() { @override public void done(parseexception e) { } }); } } }); } });
Comments
Post a Comment