简体   繁体   中英

android update record and requery

Developing an application that displays data retrieved from it's database in the initial screen. Users can edit the data via a separate edit screen. Exiting the edit screen returns the user to the initial display screen, I requery the database but the data returned is the values prior to the edit.

I am using a db provider model and have tried:

  • closing the cursor used in the initial database lookup
  • using a separate cursor each time returning to the initial screen
  • using a separate query to get the data displayed on the edit screen
  • ensure that each cursor used is closed when work with that cursors data is complete

Database queries and relaunching the application shows the edited values so I am sure that the update is working. What am I missing?

Found that the issue was related to misunderstanding states in the class used to support the editor function. Thought the onStop() and onDestroy() would be called when exiting the edit screen and was calling the method to update the database in those methods.

Changed to use onBackPressed() instead and complete the update process before the updated values are displayed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM