Modify Cursor columns value in android

≡放荡痞女 提交于 2019-12-05 13:42:27
Barak

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.

You cannot alter values returned by Cursor. You either need to update your database, hence changing the values pointed by returned cursor or copy the values you get using getXXX into other variables.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!