android - What to do with Cursor after a SQLite query? -
this first time using database , i'm not sure how works. made database , made query returns cursor and... what? cursor, really? can use navigate through data or have put in arraylist or listactivity or what?
you need iterate cursor results.
use cursor.movetofirst()
and/or cursor.movetonext()
(with while loop). can use getx() method, cursor.getint()
or cursor.getstring()
.
for example, ir expecting 1 result query:
if (cursor.movetofirst()) { string name = cursor.getstring(cursor.getcolumnindex('name')); int age = cursor.getint(cursor.getcolumnindex('age')); } else { // oops nothing found! }
Comments
Post a Comment