07-08 17:04:34.978: E/AndroidRuntime(322): FATAL EXCEPTION: main
07-08 17:04:34.978: E/AndroidRuntime(322): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gurpswu.gurps/com.gurpswu.gurps.Home}: java.lang.NullPointerException
07-08 17:04:34.978: E/AndroidRuntime(322): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-08 17:04:34.978: E/AndroidRuntime(322): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-08 17:04:34.978: E/AndroidRuntime(322): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-08 17:04:34.978: E/AndroidRuntime(322): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-08 17:04:34.978: E/AndroidRuntime(322): at android.os.Handler.dispatchMessage(Handler.java:99)
07-08 17:04:34.978: E/AndroidRuntime(322): at android.os.Looper.loop(Looper.java:123)
07-08 17:04:34.978: E/AndroidRuntime(322): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-08 17:04:34.978: E/AndroidRuntime(322): at java.lang.reflect.Method.invokeNative(Native Method)
07-08 17:04:34.978: E/AndroidRuntime(322): at java.lang.reflect.Method.invoke(Method.java:507)
07-08 17:04:34.978: E/AndroidRuntime(322): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-08 17:04:34.978: E/AndroidRuntime(322): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-08 17:04:34.978: E/AndroidRuntime(322): at dalvik.system.NativeStart.main(Native Method)
07-08 17:04:34.978: E/AndroidRuntime(322): Caused by: java.lang.NullPointerException
07-08 17:04:34.978: E/AndroidRuntime(322): at com.gurpswu.gurps.Player.getIntField(Player.java:153)
07-08 17:04:34.978: E/AndroidRuntime(322): at com.gurpswu.gurps.Home.hudSetup(Home.java:102)
07-08 17:04:34.978: E/AndroidRuntime(322): at com.gurpswu.gurps.Home.onCreate(Home.java:25)
07-08 17:04:34.978: E/AndroidRuntime(322): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-08 17:04:34.978: E/AndroidRuntime(322): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-08 17:04:34.978: E/AndroidRuntime(322): ... 11 more
我有一个游戏。当用户第一次打开应用程序并按下继续游戏按钮时,游戏将尝试使用下面的代码从数据库中检索值。
stats.open();
playerId = stats.getIntField(stats.KEY_ROWID);
String playerName = stats.getStringField(stats.KEY_NAME);
String playerCity = stats.getStringField(stats.KEY_CITY);
playerHealth = stats.getIntField(stats.KEY_HEALTH);
playerEnergy = stats.getIntField(stats.KEY_ENERGY);
playerRank = stats.getIntField(stats.KEY_RANK);
playerCash = stats.getIntField(stats.KEY_CASH);
stats.close();
但是,这些数据库字段均未填充...如何安装检查...以便仅在数据库存在时运行此代码。如果它不存在,那么它将要求玩家开始一个新游戏。