I'm an android novice and I have a problem with my cursor. I can't access the data using:
cursor.get(cursor.getColumnIndex(columnName));
I tried the following code to test for an error:
while (cursor.moveToNext()) {
int x = 2;
Log.i("MyDebug", "Index: " + x);
Log.i("MyDebug", "Name: " + cursor.getColumnName(x));
Log.i("MyDebug", "Index again: " + cursor.getColumnIndex(cursor.getColumnName(x)));
}
Result from the Debug Monitor:
Index: 2
Name: mainMenu.title
Index again: -1
Shouldn't the result of "Index again" be 2? What am I doing wrong?
cursor.getColumnIndex()
expects the name of the column, without the name of the table:
cursor.getColumnIndex("mainMenu.title"); // -1
cursor.getColumnIndex("title"); // 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With