在Android的SQL游标 [英] SQL cursors in android

查看:70
本文介绍了在Android的SQL游标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我运行一些查询和获取,我要用来更新数据库的条目的光标。如果在光标不关闭数据库的更新,会发生什么?例如,假设光标在结果集中的第一个条目指向我运行一个查询,更新的第10部分。请问当前光标反映这些变化?

Suppose I run some query and get a cursor which I want to use to update the entries in the database. What happens if the database is updated while the cursor is not closed? For example, suppose the cursor is pointing at the 1st entry in the result set and I run a query that updates the 10th element. Does the current cursor reflect those changes?

推荐答案

光标在内存中的结果的副本,这样你就可以随意修改数据库。因为它是一个副本,它不会反映任何的变化 - 你需要重新查询该

The cursor is a copy of the results in memory, so you can modify the database at will. Since it's a copy, it won't reflect any changes - you'd need to requery for that.

然而,这是绝对必要的,你尽快将其关闭,以节省存储空间,使当你切换活动,您的应用程序不会崩溃。

However, it is absolutely imperative that you close it as soon as possible, to save memory and to make your app not crash when you switch activities.

这篇关于在Android的SQL游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆