0
使用Parse.com,我想從本地數據庫檢索一個對象,更新一個字段,並將其保存回解析雲......這是我的代碼到目前爲止:IllegalArgumentException當試圖更新一個對象與解析
String objId = getIntent().getStringExtra("EXTRA_OBJ_ID");
ParseQuery<ParseObject> query = ParseQuery.getQuery("someTable");
query.fromLocalDatastore();
query.getInBackground(objId, new GetCallback<ParseObject>() {
@Override
public void done(ParseObject parseObject, ParseException e) {
if (e == null) {
Date expiry = parseObject.getDate("expiryDate");
long millis = expiry.getTime();
Date current = new Date();
parseObject.add("expiryDate", current);
parseObject.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
//success
} else {
Log.e(TAG, e.toString());
}
}
});
} else {
Log.e(TAG, e.toString());
}
}
});
但parseObject.add("expiryDate", current);
我得到以下異常:
java.lang.IllegalArgumentException: Operation is invalid after previous operation.
at com.parse.ParseAddOperation.apply(ParseAddOperation.java:71)
at com.parse.ParseObject.performOperation(ParseObject.java:2725)
at com.parse.ParseObject.addAll(ParseObject.java:2813)
at com.parse.ParseObject.add(ParseObject.java:2799)
at com.app.ConversationActivity$8.done(ConversationActivity.java:297)
at com.app.ConversationActivity$8.done(ConversationActivity.java:283)
at com.parse.Parse$5$1.run(Parse.java:924)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5151)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
at dalvik.system.NativeStart.main(Native Method)
我的代碼幾乎是從解析文檔複製粘貼,但我是從本地數據存儲,查詢...所以我怎麼能做出這項工作? 非常感謝!