Modify Cursor columns value in android

android, android-cursor

Solution

You can't change the cursor.

What you can do is update your database and then use the `reQuery()` method.

// code to update your db
cursor.requery();

EDIT

Further research show that apparently I am incorrect. You CAN do what you want, but it's quite a bit of work (and no, I haven't tried it, I just requery my cursor).

I found this (using a Google search) on a forum:

You can subclass SQLiteDatabase.CursorFactory to return, from its newCursor method, a subclass of SQLiteCursor. This factory gets passed to the SQLiteOpenHelper constructor so, when you query it, it will return Cursors of your new SQLiteCursor subclass type. The SQLiteCursor subclass can then expose methods that manage its protected mWindow field, which is a CursorWindow. This object has putXxx methods to manipulate the data.

Problem

I have a Cursor returned From a SQLiteDataBase object. I can use getXXX() to get the content of columns from the cursor, but in my case I want to modify "update" data in the cursor using `setXXX()` method. I know there is no `setXXX()` methods, but there is CursorWindow object that has this feature. However, I can't seem to use it .

Original source