What's probably happening is that you are not closing the old database file, so the application continues to read from it, and not from the new one.

This is entirely possible on Linux (and other Unixes): deleting an open file is allowed, the applications don't notice, and the actual file data is deallocated when it's finally closed (gracefully or not).

You can see the code here, all it does it deletes the file, there is no magic code to handle you switching the database underneath:

http://www.google.com/codesearch#oOy_5JrVRNM/trunk/frameworks/base/core/java/android/app/ApplicationContext.java&q=deleteDatabase%20package:android%20lang:%5Ejava$&type=cs&l=479

An ugly hack of a solution would be to terminate your application's process (and immediately restart it), so the new process can open the new database file.

A possibly complicated solution would be to close the old database file using SQLiteOpenHelper.close, and then open the new one.

As for me, I would do this: keep the existing database open, and run an intelligent merge with the new data.

-- Kostya

07.08.2011 16:04, CocoRambo ?????:
Hi,

For a new application I try to make weekly data update by downloading directly an SQLite file generated in PHP.
So when update is needed I:

  * Download the new SQLite file in ZIP (mydb.zip)
  * Extract to a temporary file (mydb.db)
  * Delete the old one (application.db via
    deleteDatabase("application.db"))
  * Put the new one instead (mydb.db becomes application.db)

But when I go back to any of my listviews, data still come from the old SQLite file.

I tried to only delete old SQLite file (All it's ok and I can check thah the file is really deleted via DDMS)
but my listviews data are still present...


Each of my ListFragment uses CursorLoader + Custom adapter that extends CursorAdapter It seems that loader is (re)created each time the fragment is created so I don't think the problem is from this side...


Does anyone have same experience with SQLite database use?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
Kostya Vasilyev

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to