0

I noticed that my app loses the files stored in the device storage after an update from the Market. I use openFileOutput() to fetch a directory to store my important files, as is specified here. I'd expect that these files would be kept between updates, but it does not seem to be the case, at least with Froyo. If this behavior is correct, how should I store my files in a manner that they won't be deleted after an update?

hgm
  • 92
  • 2
  • 9

1 Answers1

2

I noticed that my app loses the files stored in the device storage after an update from the Market.

All files are kept around on an upgrade. Files will be deleted if:

  • the user uninstalls the app
  • the user uses the Clear Data option in Settings

Also, if you change android:sharedUserId, your files are not deleted, but they will be owned by the previous user ID, meaning your app will be permanently messed up until the user unininstalls and reinstalls.

I'd expect that these files would be kept between updates

They are.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Well, so I need to investigate this issue further. My app does load the data on the file correctly every time it starts, but when it updates it seems that this data is lost. I'll accept your answer when I check that out, thanks for your reply! – hgm Mar 12 '12 at 13:25
  • I just noticed what happened. The problem was that I forgot to configure Proguard to ignore my Serializable class, and thus it failed to load it beacuse Proguard changed its name. More details can be found [here](http://stackoverflow.com/questions/6014806/android-classnotfoundexception-when-passing-serializable-object-to-activity) – hgm Mar 13 '12 at 03:33
  • @hgm: Yeah, `Serializable` is going to be prone to issues like that. Personally, I persist in anything *but* `Serializable`. Why persist in a fragile format that you can't readily debug by Mark I Eyeball? I'd rather save to SQLite, JSON, or XML. – CommonsWare Mar 13 '12 at 11:01