get row by name not working in sqlite android -


i trying 1 row passing string, returning null. idea?

main.java

int close = 0; string companies=company.gettext().tostring(); cursor port=mydb.getrowlasttran(companies); close=port.getint(2); port.close(); 

dbadapter.java

public cursor getrowlasttran(string company) {     string = key_companies + "= '" + company+"'";     cursor c = db.query( database_table_lasttran, all_keys_lasttran, where, null, null, null, null, null);     if (c != null) {         c.movetofirst();     }     return c; } 

here logcat

03-24 04:00:26.246: e/androidruntime(27711): fatal exception: main 03-24 04:00:26.246: e/androidruntime(27711): process: com.example.merostock, pid: 27711 03-24 04:00:26.246: e/androidruntime(27711): java.lang.illegalstateexception: not execute method of activity 03-24 04:00:26.246: e/androidruntime(27711):    @ android.view.view$1.onclick(view.java:3823) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.view.view.performclick(view.java:4438) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.view.view$performclick.run(view.java:18422) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.os.handler.handlecallback(handler.java:733) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.os.handler.dispatchmessage(handler.java:95) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.os.looper.loop(looper.java:136) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.app.activitythread.main(activitythread.java:5017) 03-24 04:00:26.246: e/androidruntime(27711):    @ java.lang.reflect.method.invokenative(native method) 03-24 04:00:26.246: e/androidruntime(27711):    @ java.lang.reflect.method.invoke(method.java:515) 03-24 04:00:26.246: e/androidruntime(27711):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 03-24 04:00:26.246: e/androidruntime(27711):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 03-24 04:00:26.246: e/androidruntime(27711):    @ dalvik.system.nativestart.main(native method) 03-24 04:00:26.246: e/androidruntime(27711): caused by: java.lang.reflect.invocationtargetexception 03-24 04:00:26.246: e/androidruntime(27711):    @ java.lang.reflect.method.invokenative(native method) 03-24 04:00:26.246: e/androidruntime(27711):    @ java.lang.reflect.method.invoke(method.java:515) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.view.view$1.onclick(view.java:3818) 03-24 04:00:26.246: e/androidruntime(27711):    ... 11 more 03-24 04:00:26.246: e/androidruntime(27711): caused by: android.database.cursorindexoutofboundsexception: index 0 requested, size of 0 03-24 04:00:26.246: e/androidruntime(27711):    @ android.database.abstractcursor.checkposition(abstractcursor.java:426) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.database.abstractwindowedcursor.checkposition(abstractwindowedcursor.java:136) 03-24 04:00:26.246: e/androidruntime(27711):    @ android.database.abstractwindowedcursor.getint(abstractwindowedcursor.java:68) 03-24 04:00:26.246: e/androidruntime(27711):    @ com.example.merostock.addportfolio.addportfolio(addportfolio.java:66) 03-24 04:00:26.246: e/androidruntime(27711):    ... 14 more 

you should use this

db.query(tablename, null, "colum_name=?",new string[]{value query}, null, null, null); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -