public Cursor getsomething()
{
this.open();
Cursor c= database.query(DatabaseHandler.Table_Name,magicdata,null, null, null,null,null);
this.close();
return c;
}
我正在使用此代码来查询我的数据库。然后我在主要活动中调用它。
get=X.getsomething();
if (get.getCount() > 0)
{
if (get.moveToFirst())
{
do {
String uname = get.getString(get.getColumnIndex("content_id"));
String unknown =url + uname;
String ax= get.getString(get.getColumnIndex("content"));
downloadimages(url,ax);
}
while (get.moveToNext());
}
}
}}
我在error
这里得到一个,我的代码没有运行,我不知道为什么?
错误代码如下
02-20 10:27:18.378: E/PhonePolicy(1261): Could not preload class for phone policy com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback
02-20 10:27:18.488: D/TextLayoutCache(1261): Using debug level: 0 - Debug Enabled: 0
02-20 10:27:20.998: D/AndroidRuntime(1261): Shutting down VM
02-20 10:27:20.998: W/dalvikvm(1261): threadid=1: thread exiting with uncaught exception (group=0x40a3e1f8)
02-20 10:27:20.998: E/AndroidRuntime(1261): FATAL EXCEPTION: main
02-20 10:27:20.998: E/AndroidRuntime(1261): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newpicker/com.example.newpicker.MainActivity}: java.lang.IllegalStateException: database /data/data/com.example.newpicker/databases/content.db (conn# 0) already closed
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.os.Handler.dispatchMessage(Handler.java:99)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.os.Looper.loop(Looper.java:137)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.app.ActivityThread.main(ActivityThread.java:4429)
02-20 10:27:20.998: E/AndroidRuntime(1261): at java.lang.reflect.Method.invokeNative(Native Method)
02-20 10:27:20.998: E/AndroidRuntime(1261): at java.lang.reflect.Method.invoke(Method.java:511)
02-20 10:27:20.998: E/AndroidRuntime(1261): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
02-20 10:27:20.998: E/AndroidRuntime(1261): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
02-20 10:27:20.998: E/AndroidRuntime(1261): at dalvik.system.NativeStart.main(Native Method)
02-20 10:27:20.998: E/AndroidRuntime(1261): Caused by: java.lang.IllegalStateException: database /data/data/com.example.newpicker/databases/content.db (conn# 0) already closed
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.database.sqlite.SQLiteDatabase.verifyDbIsOpen(SQLiteDatabase.java:2082)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase.java:413)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase.java:400)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:79)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
02-20 10:27:20.998: E/AndroidRuntime(1261): at com.example.newpicker.MainActivity.datamining(MainActivity.java:70)
02-20 10:27:20.998: E/AndroidRuntime(1261): at com.example.newpicker.MainActivity.onCreate(MainActivity.java:45)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.app.Activity.performCreate(Activity.java:4465)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-20 10:27:20.998: E/AndroidRuntime(1261): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-20 10:27:20.998: E/AndroidRuntime(1261): ... 11 more