如何从市场升级时重置应用状态 [英] How to reset an application states when upgrading from the market

查看:106
本文介绍了如何从市场升级时重置应用状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个开发人员,我已经发布了市场上的应用程序。当用户下载新版本,我要清理其状态(共享preferences,SQLite的模式......)应用程序。我读到 SQLiteOpenHelper 。我想,当我加载Eclipse中的设备上创建新的apk,应用程序仍保持其previous共享preferences。如果数据库架构发生变化,应用程序会崩溃。

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 ?

推荐答案

要你的问题,你应该能够触发使用SQLiteOpenHelper <一个数据库更新href=\"http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html#onUpgrade%28android.database.sqlite.SQLiteDatabase,%20int,%20int%29\"相对=nofollow> OnUpgrade (其他城市DATABASE_VERSION在你的类),要么调用从那里功能来清除preferences或添加标志的分贝,这和做它在你的主程序。

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.

这篇关于如何从市场升级时重置应用状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆