android - "select where" not work -


in databaseadapter class, write method getall that

public list<alluserinfor> getallinfor(int id) {     list<alluserinfor> allinfor = new arraylist<alluserinfor>();      string selectquery = "select name, gender my_table _id = '"+id+"' ";      cursor cursor = sqlitedatabase.rawquery(selectquery, null);       if (cursor.movetofirst()) {         {             alluserinfor alluserinfor = new alluserinfor();                            alluserinfor.setname(cursor.getstring(1));             alluserinfor.setgender(cursor.getstring(2));                             allinfor.add(alluserinfor);         } while (cursor.movetonext());     }       return allinfor; } 

and in second activity, have

@override public void onclick(view v) {     // todo auto-generated method stub      switch (v.getid()) {      case r.id.btshow:         // id first activity         bundle extras = getintent().getextras();         id = extras.getint("roomid");         list<alluserinfor> userinfor = mysqliteadapter.getallinfor(id);         (alluserinfor aui : userinfor){             tvname.settext(aui.getname());             tvgender.settext(aui.getgender());          }         break;     }  } 

this way id first activity

lvroom.setonitemclicklistener(new adapterview.onitemclicklistener() {          @override         public void onitemclick(adapterview<?> listview, view view,                 int position, long id) {             // todo auto-generated method stub             cursor = (cursor) lvroom.getitematposition(position);             int item_id = cursor.getint(cursor.getcolumnindex(sqliteadapter.key_id));              intent = new intent();             bundle bundle = new bundle();             bundle.putint("roomid", item_id);                            i.putextras(bundle);             i.setclass(firstactivity.this, secondactivity.class);             startactivityforresult(i, 0);          } 

after hit show button inf second activity, nothing change, mean name , gender not showed in second layout. mistakes? me

this logcat

03-10 18:01:20.790: e/androidruntime(1224): fatal exception: main 03-10 18:01:20.790: e/androidruntime(1224): java.lang.nullpointerexception 03-10 18:01:20.790: e/androidruntime(1224):     @ com.superman.medreport.secondactivity.onclick(secondactivity.java:127) 03-10 18:01:20.790: e/androidruntime(1224):     @ android.view.view.performclick(view.java:4204) 03-10 18:01:20.790: e/androidruntime(1224):     @ android.view.view$performclick.run(view.java:17355) 03-10 18:01:20.790: e/androidruntime(1224):     @ android.os.handler.handlecallback(handler.java:725) 03-10 18:01:20.790: e/androidruntime(1224):     @ android.os.handler.dispatchmessage(handler.java:92) 03-10 18:01:20.790: e/androidruntime(1224):     @ android.os.looper.loop(looper.java:137) 03-10 18:01:20.790: e/androidruntime(1224):     @ android.app.activitythread.main(activitythread.java:5041) 03-10 18:01:20.790: e/androidruntime(1224):     @ java.lang.reflect.method.invokenative(native method) 03-10 18:01:20.790: e/androidruntime(1224):     @ java.lang.reflect.method.invoke(method.java:511) 03-10 18:01:20.790: e/androidruntime(1224):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 03-10 18:01:20.790: e/androidruntime(1224):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 03-10 18:01:20.790: e/androidruntime(1224):     @ dalvik.system.nativestart.main(native method) 03-10 18:01:24.802: e/trace(1256): error opening trace file: no such file or directory (2) 

do not cast id value string integer in table.

change criteria below value:

"select name, gender my_table _id = "+id+" "; 

just remove single " ' " , write "+id+" not '"+id+"'


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -