如何删除安装并重新安装应用程序数据 [英] How to delete application data on install and reinstall

查看:163
本文介绍了如何删除安装并重新安装应用程序数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何删除上安装/重新安装应用程序的数据,这样我就可以对每一个重新安装全新的工作环境?
我的意思是如何检测,这个应用程序已被重新安装,所以我可以清洗整个持久性存储。
谢谢你。

How to delete application data on install/reinstall application, so I can have a clean working environment on every reinstall ? I mean how to detect that this application has been reinstalled so I can clean the whole persistent store. Thanks.

推荐答案

在5.0的API有一个叫新类<一href=\"http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/$c$cModuleListener.html\"相对=nofollow> codeModuleListener ,你可以使用时,正在卸载的模块进行监控。之前5.0虽然,没有挂钩。然而,这里有一些想法去思考和/或尝试:

In the 5.0 APIs there is a new class called CodeModuleListener which you could use to monitor when your modules are being uninstalled. Prior to 5.0 though, there are no hooks. However, here are a few ideas to think about and/or try:


  1. 使用的<一个href=\"http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/$c$cModuleManager.html\"相对=nofollow> codeModuleManager 方法getModuleDownloadTimestamp()或getModuleTimestamp()(不知道哪一个会给予适当的信息)来查找模块的安装时间,然后将其存储在持久性。然后每个应用程序启动时,请再次阅读从模块的价值和比较它持久的价值。如果模块值更新,然后应用程序被重新安装。

  1. Use the CodeModuleManager methods getModuleDownloadTimestamp() or getModuleTimestamp() (not sure which one would give the proper information) to look up the "install time" of the module, then store it in persistence. Then each time the app is started, read the value from the module again and compare it to the persisted value. If the module value is newer, then the app was reinstalled.

如果您存储在持久性存储非本地类(即哈希表的一个子类),它会从持久存储在卸载应用程序删除(因为如果没有应用程序,类是没有意义的) 。因此,所有你需要做的就是创建哈希表的一个子类,并存储在你的持久性存储(与你的实际数据为密钥),它会从用户卸载应用程序商店被自动删除。

If you store a non-native class in the Persistent Store (i.e. a subclass of Hashtable), it will be removed from the persistent store when you uninstall the app (since without the app, the class is meaningless). So all you need to do is create a subclass of Hashtable and store that in your persistent store (with your actual data as keys), and it will be automatically removed from the store when the user uninstalls the app.

这篇关于如何删除安装并重新安装应用程序数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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