進出口行試圖從給定的使用下面的代碼行的行中的名稱值的表中刪除一行:找不到什麼是錯的語法來刪除源碼
db.delete(Table, Column_Name+"="+ col_value, null);
創建的表使用:
db.execSQL("create table"+ Table+"("+Column_Name+" text," +Id+" integer primary key)");
Logcat在刪除行的行顯示NPE。它有什麼不對?
logcat的:
07-31 18:00:13.267: E/AndroidRuntime(1264): java.lang.IllegalStateException: Could not execute method of the activity
07-31 18:00:13.267: E/AndroidRuntime(1264): at android.view.View$1.onClick(View.java:2072)
07-31 18:00:13.267: E/AndroidRuntime(1264): at android.view.View.performClick(View.java:2408)
07-31 18:00:13.267: E/AndroidRuntime(1264): at android.view.View$PerformClick.run(View.java:8816)
07-31 18:00:13.267: E/AndroidRuntime(1264): at android.os.Handler.handleCallback(Handler.java:587)
07-31 18:00:13.267: E/AndroidRuntime(1264): at android.os.Handler.dispatchMessage(Handler.java:92)
07-31 18:00:13.267: E/AndroidRuntime(1264): at android.os.Looper.loop(Looper.java:123)
07-31 18:00:13.267: E/AndroidRuntime(1264): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-31 18:00:13.267: E/AndroidRuntime(1264): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 18:00:13.267: E/AndroidRuntime(1264): at java.lang.reflect.Method.invoke(Method.java:521)
07-31 18:00:13.267: E/AndroidRuntime(1264): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-31 18:00:13.267: E/AndroidRuntime(1264): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-31 18:00:13.267: E/AndroidRuntime(1264): at dalvik.system.NativeStart.main(Native Method)
07-31 18:00:13.267: E/AndroidRuntime(1264): Caused by: java.lang.reflect.InvocationTargetException
07-31 18:00:13.267: E/AndroidRuntime(1264): at com.example.databaseaccess.MainActivity.deleteone(MainActivity.java:70)
07-31 18:00:13.267: E/AndroidRuntime(1264): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 18:00:13.267: E/AndroidRuntime(1264): at java.lang.reflect.Method.invoke(Method.java:521)
07-31 18:00:13.267: E/AndroidRuntime(1264): at android.view.View$1.onClick(View.java:2067)
07-31 18:00:13.267: E/AndroidRuntime(1264): ... 11 more
07-31 18:00:13.267: E/AndroidRuntime(1264): Caused by: java.lang.NullPointerException
07-31 18:00:13.267: E/AndroidRuntime(1264): at com.example.databaseaccess.DbHelper.fdelete(DbHelper.java:145)
07-31 18:00:13.267: E/AndroidRuntime(1264): ... 15 more
線144: 「?」 的字符串S =名稱+ 「=」 +;
145行:db.delete(Table,s,new String [] {i});
NPE可能意味着你的數據庫是空 – njzk2
給每一個單詞之間的空格在布萊克斯。 –
它有記錄pal。唯一的問題是刪除行語法缺少一些東西。 – VijayaRagavan