ac4android
Well-Known Member
I am trying to print the values from several columns in my SQLite table by plugging my CursorAdapter into my ListView, like this:
Currently it is returning only the first field (Projectname) from the cursor, and not the others.
Is there a quick fix to this or do I need to create my own adapter class?
I am importing "android.widget.ListView" because I don't have to code a layout file
Code:
import android.widget.ListView;
...
ListView listProjectmanagers = getListView();
try{
SQLiteOpenHelper assetlocationDBhelper = new AssetLocationDBHelper(this);
SQLiteDatabase db = assetlocationDBhelper.getWritableDatabase();
Cursor cursor = db.query("PROJECTS",
new String[]{"_id", "Projectname", "Managername"},
null, null, null, null, null);
CursorAdapter listAdapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1,
cursor,
new String[]{"Projectname", "Managername"},
new int[]{android.R.id.text1},
0);
// ...plug it into the outlet
listProjectmanagers.setAdapter(listAdapter);
//cursor.close();
//db.close();
} catch(SQLiteException sx) {
Toast toast = Toast.makeText(this, "ERROR Database unavailable", Toast.LENGTH_SHORT);
toast.show();
}
}
Currently it is returning only the first field (Projectname) from the cursor, and not the others.
Is there a quick fix to this or do I need to create my own adapter class?
I am importing "android.widget.ListView" because I don't have to code a layout file

Last edited: