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

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -