android - Can't find whats wrong in the syntax to delete a row in sqlite -
im trying delete row table given name value in row using following line of code:
db.delete(table, column_name+"="+ col_value, null);
created table using:
db.execsql("create table"+ table+"("+column_name+" text," +id+" integer primary key)");
logcat shows npe @ line of deleting row. whats wrong there in it?
logcat:
07-31 18:00:13.267: e/androidruntime(1264): java.lang.illegalstateexception: not execute method of activity 07-31 18:00:13.267: e/androidruntime(1264): @ android.view.view$1.onclick(view.java:2072) 07-31 18:00:13.267: e/androidruntime(1264): @ android.view.view.performclick(view.java:2408) 07-31 18:00:13.267: e/androidruntime(1264): @ android.view.view$performclick.run(view.java:8816) 07-31 18:00:13.267: e/androidruntime(1264): @ android.os.handler.handlecallback(handler.java:587) 07-31 18:00:13.267: e/androidruntime(1264): @ android.os.handler.dispatchmessage(handler.java:92) 07-31 18:00:13.267: e/androidruntime(1264): @ android.os.looper.loop(looper.java:123) 07-31 18:00:13.267: e/androidruntime(1264): @ android.app.activitythread.main(activitythread.java:4627) 07-31 18:00:13.267: e/androidruntime(1264): @ java.lang.reflect.method.invokenative(native method) 07-31 18:00:13.267: e/androidruntime(1264): @ java.lang.reflect.method.invoke(method.java:521) 07-31 18:00:13.267: e/androidruntime(1264): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 07-31 18:00:13.267: e/androidruntime(1264): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 07-31 18:00:13.267: e/androidruntime(1264): @ 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): @ com.example.databaseaccess.mainactivity.deleteone(mainactivity.java:70) 07-31 18:00:13.267: e/androidruntime(1264): @ java.lang.reflect.method.invokenative(native method) 07-31 18:00:13.267: e/androidruntime(1264): @ java.lang.reflect.method.invoke(method.java:521) 07-31 18:00:13.267: e/androidruntime(1264): @ 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): @ com.example.databaseaccess.dbhelper.fdelete(dbhelper.java:145) 07-31 18:00:13.267: e/androidruntime(1264): ... 15 more
line 144: string s = name+"="+"?";
line 145: db.delete(table,s,new string[]{i});
the table not created in first place:
"create table"+ table+"("
make sure there space between "create table" , name. should be
"create table "+ table+"("
Comments
Post a Comment