我有一个Cursor返回从SQLiteDataBase对象,我可以使用getXXX()从光标获取列的内容,在我的情况下,我想使用setXXX()方法修改游标中的“更新”数据,我知道有没有setXXX()方法,但有CursorWindow对象具有此功能,但我无法使用它
解决方法:
您无法更改光标.
您可以做的是更新数据库,然后使用reQuery()方法.
// code to update your db
cursor.requery();
编辑
进一步的研究表明,显然我是不正确的.你可以做你想做的事,但这是相当多的工作(不,我没有尝试过,我只是重新查询我的光标).
我在论坛上发现了这一点(使用谷歌搜索):
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.
标签:android,cursor
来源: https://codeday.me/bug/20190530/1183439.html