我在ListView
中显示我的数据库。我使用名为Button
的{{1}}来显示数据库。当我点击它时,应用程序崩溃了。这是堆栈跟踪:
find geopoint
这是我的代码:
08-25 17:03:11.308: ERROR/AndroidRuntime(8373): Uncaught handler: thread main exiting due to uncaught exception
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cortes/com.cortes.Display}: java.lang.IllegalStateException: get field slot from row 1 col -1 failed
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.os.Handler.dispatchMessage(Handler.java:99)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.os.Looper.loop(Looper.java:123)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.app.ActivityThread.main(ActivityThread.java:4363)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at java.lang.reflect.Method.invokeNative(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at java.lang.reflect.Method.invoke(Method.java:521)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at dalvik.system.NativeStart.main(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): Caused by: java.lang.IllegalStateException: get field slot from row 1 col -1 failed
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.database.CursorWindow.getString_native(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.database.CursorWindow.getString(CursorWindow.java:363)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at com.cortes.Display.onCreate(Display.java:116)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): ... 11 more
这是我的c = db.query(Geo_Create_Table, new String[ {"_id","latitude","longitude","address"}, null,null, null, null, null);
x1 = c.getColumnIndex("_id");
y1 = c.getColumnIndex("latitude");
z1 = c.getColumnIndex("longiitude");
w1 = c.getColumnIndex("address");
while(c.moveToNext()) {
a = c.getInt(x1);
b1 = c.getString(y1);
c1 = c.getString(z1);
e = c.getString(w1);
results.add(a+"" + " " + b1 + " " + c1 + " " + e);
}
ArrayAdapter<String> a11=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, results);
lv.setAdapter(a11);
文件:
AndroidManifest.xml
有关如何解决此问题的任何建议?