android - illegalstateexception in displaying list view -


i getting error displaying content in listview. error says:

 05-03 08:00:13.575: e/androidruntime(3341): java.lang.runtimeexception: unable start activity                    componentinfo{com.android.lthomepage/com.android.lthomepage.listviewdetails}: java.lang.illegalargumentexception:    column '_id' not exist 05-03 08:00:13.575: e/androidruntime(3341):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.app.activitythread.access$600(activitythread.java:141) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.os.handler.dispatchmessage(handler.java:99) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.os.looper.loop(looper.java:137) 05-03 08:00:13.575: e/androidruntime(3341): caused by: java.lang.illegalargumentexception: column '_id' not exist 05-03 08:00:13.575: e/androidruntime(3341):     @ android.database.abstractcursor.getcolumnindexorthrow(abstractcursor.java:303) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.support.v4.widget.cursoradapter.init(cursoradapter.java:174) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.support.v4.widget.cursoradapter.<init>(cursoradapter.java:151) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.support.v4.widget.resourcecursoradapter.<init>(resourcecursoradapter.java:93) 05-03 08:00:13.575: e/androidruntime(3341):     @ android.support.v4.widget.simplecursoradapter.<init>(simplecursoradapter.java:89) 05-03 08:00:13.575: e/androidruntime(3341):     @ com.android.lthomepage.listviewdetails.displaylistview(listviewdetails.java:77) 05-03 08:00:13.575: e/androidruntime(3341):     @       com.android.lthomepage.listviewdetails.oncreate(listviewdetails.java:42) 

the listview code follows:

    cursor cursor=way.fetchdetails();     string[] columns=new string[] {waydatabase.key_name,waydatabase.key_appno,waydatabase.key_amount};      int[] to=new int[] {r.id.name,             r.id.continent,             r.id.region};      adapter=new simplecursoradapter(this, r.layout.country_info, cursor, columns, to, 0);      listview listview=getlistview();     listview.setadapter(adapter); 

the database code is:

public cursor fetchdetails() {      createallvaluestable();     cursor mcursor=db.query(allvaluestable, new string[] {key_name,key_appno,key_amount}, null, null, null, null, null);       if (mcursor != null) {            mcursor.movetofirst();           }           return mcursor; } 

what problem cant seem figure out?? dnt dont have column _id , dnt noe wer showing this! please help! thanks!

from android developer site

adapter exposes data cursor listview widget. cursor must include column named "_id" or class not work.

you trying use cursor simplecursoradapter requires column called _id. simple editing table creation statement , adding column called _id. declaration should follow

_id integer primary key autoincrement


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -