1

As a developer, I have applications already published on the market. When users download the new version, I want the application to clean its states ( SharedPreferences , SQLite schema ... ). I read about SQLiteOpenHelper. I suppose when I'm loading a new .apk on the device from Eclipse, the app still keeps its previous SharedPreferences . If the DB schema changed, the app will crash.

Is it possible to trigger a "clean states" when the application is being upgraded from the market ?

RivieraKid
  • 5,923
  • 4
  • 38
  • 47
Raymond Chenon
  • 11,482
  • 15
  • 77
  • 110
  • Totally agree with @onik, but to be honest, there should be no reason why you couldn't migrate or "upgrade" shared preferences along with the database. – RivieraKid Aug 16 '11 at 14:51
  • @ RivieraKid Thanks for migrating this question. As a new user on Android exchange, I could not delete it. But I opened a similar on SO stackoverflow.com/questions/7076622/… . BTW I ask how to reset every states not just the database or SharedPreferences. – raychenon – Raymond Chenon Aug 17 '11 at 09:21

1 Answers1

3

To your question, you should be able to trigger a database update using SQLiteOpenHelper OnUpgrade (change DATABASE_VERSION in your class) and either call a function from there to clear the preferences or add a flag to the db for this and do it in your main program.

ale
  • 6,369
  • 7
  • 55
  • 65
onik
  • 1,922
  • 1
  • 18
  • 32