我想创建一个可以加载存储在我的 sqlite 数据库中的图像的方法。在我的数据库中,我创建了一个包含图像地址和图像标识符的表,我的目标是将每个图像放在按钮上,方法如下:
public String getImage(int i)//afficher une image
{
String res;
SQLiteStatement s = database.compileStatement ("SELECT " + COL_ADRESS_IMAGE + "FROM " + TABLE_IMAGE + "WHERE id_image IN (SELECT " + COL_IMAGE_CATEGORY +
"FROM " + TABLE_CATEGORY + "WHERE " + COL_ID_CATEGORY + "= '" +i +"')" );
res = s.toString();
return res;
}
但是这种方法不起作用,这里是 logcagt :
07-09 14:16:56.159: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:16:56.169: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:17:46.439: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:17:46.439: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:18:36.759: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:18:36.759: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:19:27.038: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:19:27.038: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:20:17.310: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:20:17.310: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:21:07.659: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:21:07.659: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:21:57.999: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:21:57.999: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:22:48.389: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:22:48.398: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:23:38.790: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:23:38.790: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:24:29.039: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:24:29.039: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:25:19.269: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:25:19.269: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:26:09.538: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:26:09.538: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:26:59.879: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:26:59.879: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:27:50.259: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:27:50.259: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:28:40.819: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:28:40.819: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:29:31.168: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:29:31.168: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:30:21.528: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:30:21.528: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:31:11.929: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:31:11.929: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:32:02.279: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:32:02.289: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:32:52.638: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:32:52.648: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:33:43.039: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:33:43.039: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:34:33.320: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:34:33.320: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:35:23.679: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:35:23.689: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:36:14.008: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:36:14.018: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:37:04.329: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:37:04.329: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:37:54.689: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:37:54.689: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:38:44.889: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:38:44.889: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:39:35.218: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:39:35.218: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:40:25.539: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:40:25.539: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:41:02.519: W/Trace(2236): Unexpected value from nativeGetEnabledTags: 0
07-09 14:41:16.119: W/Trace(2535): Unexpected value from nativeGetEnabledTags: 0
07-09 14:41:16.119: W/Trace(2535): Unexpected value from nativeGetEnabledTags: 0
07-09 14:41:16.129: W/Trace(2535): Unexpected value from nativeGetEnabledTags: 0
07-09 14:41:16.129: W/Trace(2535): Unexpected value from nativeGetEnabledTags: 0
07-09 14:41:16.739: D/dalvikvm(2535): GC_FOR_ALLOC freed 59K, 7% free 2514K/2692K, paused 105ms, total 108ms
07-09 14:41:16.829: I/dalvikvm-heap(2535): Grow heap (frag case) to 5.694MB for 3279376-byte allocation
07-09 14:41:16.949: D/dalvikvm(2535): GC_FOR_ALLOC freed 1K, 4% free 5715K/5896K, paused 90ms, total 90ms
07-09 14:41:17.069: D/dalvikvm(2535): GC_CONCURRENT freed <1K, 4% free 5715K/5896K, paused 11ms+26ms, total 120ms
07-09 14:41:18.319: D/dalvikvm(2535): GC_FOR_ALLOC freed <1K, 4% free 5715K/5896K, paused 53ms, total 53ms
07-09 14:41:18.399: I/dalvikvm-heap(2535): Grow heap (frag case) to 12.729MB for 7378576-byte allocation
07-09 14:41:18.509: D/dalvikvm(2535): GC_CONCURRENT freed 0K, 2% free 12921K/13104K, paused 18ms+28ms, total 113ms
07-09 14:41:18.919: D/AndroidRuntime(2535): Shutting down VM
07-09 14:41:18.919: W/dalvikvm(2535): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
07-09 14:41:18.959: E/AndroidRuntime(2535): FATAL EXCEPTION: main
07-09 14:41:18.959: E/AndroidRuntime(2535): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.application.activity/com.application.activity.MainActivity}: java.lang.NullPointerException
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.os.Looper.loop(Looper.java:137)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.app.ActivityThread.main(ActivityThread.java:5039)
07-09 14:41:18.959: E/AndroidRuntime(2535): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 14:41:18.959: E/AndroidRuntime(2535): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 14:41:18.959: E/AndroidRuntime(2535): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-09 14:41:18.959: E/AndroidRuntime(2535): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-09 14:41:18.959: E/AndroidRuntime(2535): at dalvik.system.NativeStart.main(Native Method)
07-09 14:41:18.959: E/AndroidRuntime(2535): Caused by: java.lang.NullPointerException
07-09 14:41:18.959: E/AndroidRuntime(2535): at com.application.database.DataBase.getImage(DataBase.java:168)
07-09 14:41:18.959: E/AndroidRuntime(2535): at com.application.activity.MainActivity.putLinearLayout(MainActivity.java:48)
07-09 14:41:18.959: E/AndroidRuntime(2535): at com.application.activity.MainActivity.onCreate(MainActivity.java:29)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.app.Activity.performCreate(Activity.java:5104)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-09 14:41:18.959: E/AndroidRuntime(2535): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-09 14:41:18.959: E/AndroidRuntime(2535): ... 11 more