在Android的SQL游标游标、Android、SQL

2023-09-06 21:49:00 作者:"__ 輪 徊。

假设我运行一些查询和获取,我要用来更新数据库的条目的光标。如果在光标不关闭数据库的更新,会发生什么?例如,假设光标在结果集中的第一个条目指向我运行一个查询,更新的第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.