Created
January 3, 2016 01:39
-
-
Save mattmcgiv/bf1c12e69d3a9cdf2b16 to your computer and use it in GitHub Desktop.
Read a Cursor in Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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