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?
相关问题
- How can I create this custom Bottom Navigation on
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Bottom Navigation View gets Shrink Down
- Difference between Types.INTEGER and Types.NULL in
You need to call
cursor.requery()
in order to reload changes from the database.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.