Android SQLite, how to get values from the column?
I see how to get the column I want, but how do I get the data associated with that column on that particular row (given the ro开发者_如何学编程wID) using a Cursor object or SQLiteDatabase object.
Thanks!
To get the specific value from the database column you need to use the collection framework class like ArrayList,VectorList etc. For Example
Cursor c=handler.returnData();
ArrayList<String> array=new ArrayList<String>();
while(c.moveToNext()){
String name=c.getString(c.getColumnIndex("number"));
array.add(name);
}
Toast.makeText(getBaseContext(), "name"+array.get(2), Toast.LENGTH_LONG).show();
Assume c is your instantiated cursor
c.moveToPosition(rowNumber);
精彩评论