I have a Listview that I want to populate with information from my SQLite database with and this seemed like the most practical solution. In my debugger it says it's caused by:
IllegalArgumentException No such column. Id does not exist
This is the java file I'm trying to populate it with:
data = new MyData(this);
ListView lv = (ListView) findViewById(R.id.list);
ListAdapter adapter = new SimpleCursorAdapter(
this,
R.layout.list,
data.selectData(),
new String[] {
"name",
"title"
},
new int[] {
R.id.name,
R.id.title
}
);
lv.setAdapter(adapter);
R.layout.list xml file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="8dip"/>
<TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
public Cursor selectData() {
return db.query("tbl_mydata", new String[] {"name", "abb" }, null, null, null, null, null);
}