Write to an Android Cursor
Android documentation for Cursor says
This interface provides random read-write access to the result set returned b开发者_JS百科y a database query
I could not figure out what API to modify the values using a Cursor. Is it possible to write into a Cursor?
An answer to a similar question asked on Android Beginners forum:
Yes, there is, Craig. Good question. I'll be happy to help. 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. I haven't tried this myself, so if anyone has any tips or hints, please post.
There is no way of writing to a cursor! I wonder why it says that..
精彩评论