当前位置: 动力学知识库 > 问答 > 编程问答 >

android - How to reset an application states when upgrading from the market

问题描述:

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 ?

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: