The following code snippet from my activity's onCreate()
works great (i.e. cursor.moveToFirst()
is true) in subsequent invocations of my application:
ContentValues values = new ContentValues();
values.put(MyProvider.Notes.TITLE, "title");
values.put(MyProvider.Notes.NOTE, "note");
ContentResolver cr = getContentResolver();
Uri newlyInsertedRecord = cr.insert(notesUri, values);
if (cursor.moveToFirst()) {
int id = cursor.getInt(0);
String ttl = cursor.getString(1);
String nte = cursor.getString(2);
Log.i(TAG, id + ", "+ ttl + ", "+ nte);
}
else
Log.e(TAG, "Why isn't the insert reflected immediately?");
So, I know for certain that the cr.insert()
is executed properly.
But on first invocation of my application, cursor.moveToFirst()
returns false, despite the cr.insert()
preceding it.
Why?
Do I need some sort of a "flush" or "close" statement?