Skip to content

Instantly share code, notes, and snippets.

@mattmcgiv
Created January 3, 2016 01:39
Show Gist options
  • Select an option

  • Save mattmcgiv/bf1c12e69d3a9cdf2b16 to your computer and use it in GitHub Desktop.

Select an option

Save mattmcgiv/bf1c12e69d3a9cdf2b16 to your computer and use it in GitHub Desktop.
Read a Cursor in Android
//Cursor named "result"
//if statement makes sure we actually got back some data from the db
if (result.moveToFirst() != false) {
//for each row (representing a row of db)
while (result.moveToNext() != false) {
//for each column, representing a value from the row
for (int i = 0; i < result.getColumnCount(); i++) {
Log.d("Name of db column: ", result.getColumnName(i));
String val = result.getString(i);
Log.d("Value for column: ", val);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment