开发者

Android SQLite, how to get values from the column?

开发者 https://www.devze.com 2023-03-13 12:12 出处:网络
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.

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);

0

精彩评论

暂无评论...
验证码 换一张
取 消