我有一个扩展了News
类的ParseObject
对象。我希望将其缓存在本地,以便以后可以从本地存储中获取。
这是我的回调,其中包括对.pinAllInBackground(..)
方法的调用:
FindCallback<News> onNewsReceived = new FindCallback<News>() {
@Override
public void done(List<News> arg0, ParseException arg1) {
if (arg1 == null) {
newsList = new ArrayList<News>(arg0);
ParseObject.pinAllInBackground(newsList);
initializeList();
} else {
Log.d("TAG1", String.valueOf(arg1.getMessage()));
}
}
};
当我运行此程序时,出现以下异常:
09-22 11:31:25.637: E/AndroidRuntime(27380): FATAL EXCEPTION: main
09-22 11:31:25.637: E/AndroidRuntime(27380): Process: pl.holdapp.osw, PID: 27380
09-22 11:31:25.637: E/AndroidRuntime(27380): java.lang.NullPointerException
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.ParsePin.getParsePin(ParsePin.java:19)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.ParsePin.pinAllObjectsAsync(ParsePin.java:44)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.ParseObject.pinAllAsync(ParseObject.java:3320)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.ParseObject.pinAllInBackground(ParseObject.java:3417)
09-22 11:31:25.637: E/AndroidRuntime(27380): at pl.holdapp.osw.fragments.NewsFragment$2.done(NewsFragment.java:68)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.FindCallback.internalDone(FindCallback.java:45)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.FindCallback.internalDone(FindCallback.java:31)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.parse.Parse$6$1.run(Parse.java:917)
09-22 11:31:25.637: E/AndroidRuntime(27380): at android.os.Handler.handleCallback(Handler.java:733)
09-22 11:31:25.637: E/AndroidRuntime(27380): at android.os.Handler.dispatchMessage(Handler.java:95)
09-22 11:31:25.637: E/AndroidRuntime(27380): at android.os.Looper.loop(Looper.java:157)
09-22 11:31:25.637: E/AndroidRuntime(27380): at android.app.ActivityThread.main(ActivityThread.java:5356)
09-22 11:31:25.637: E/AndroidRuntime(27380): at java.lang.reflect.Method.invokeNative(Native Method)
09-22 11:31:25.637: E/AndroidRuntime(27380): at java.lang.reflect.Method.invoke(Method.java:515)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
09-22 11:31:25.637: E/AndroidRuntime(27380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
09-22 11:31:25.637: E/AndroidRuntime(27380): at dalvik.system.NativeStart.main(Native Method)
arg0
不为null,因此我完全不知道它的来源。 最佳答案
显然,我在固定之前没有呼叫Parse.enableLocalDatastore(context);
。