android 光标cursor,修改android中的Cursor列值

我有一个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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值