android - Push SQLite3 data to an ArrayList() -


I have data on two columns "id" and "name". I try to get all names from database into an ArrayList I am doing What is the best way to call it and create an array?

Something like this will happen: array list myResults = new array List (); Cursor c = db.query (... your query parameters here ...); C.moveToFirst (); While (! C.isAfterLast ()) {myResults.add (c.getString (1)); C.moveToNext (); }

Believing that you have selected the column of the id and name in that order in your query. The name column will be 1 compared to the index.

Hope that helps.

Comments