I know that you solved your problem, but here is a step-by-step description of what happened:
Cursor mCursor = mDb.rawQuery(query, null); // At this point mCursor is positioned at just before the first record. if (mCursor != null) { mCursor.moveToFirst(); // mCursor is now pointing at the first (and only) record } while (mCursor.moveToNext()) { String result_0=cursor.getString(0); } // The loop above was skipped because `.moveToNext()` caused mCursor // to move past the last record.
So, in your case, when you need only one entry, you only need mCursor.moveToFirst() OR your mCursor.moveToNext() .
source share