怎样最容易被删除后,升级/更新的Andr​​oid应用程序的数据?最容易、应用程序、数据、oid

2023-09-05 02:09:41 作者:社会复杂爷简单

所以,我发现在一个特定的SDK,导致重新安装一个应用程序,它使用的SDK(通过ADB安装-r的新版本后,失败的一些Android手机中的错误,并且presumably时用户获取已被推到Android市场的更新)。有没有什么办法来强制应用程序的数据,自动在应用程序的更新清除?我知道有一些数据可以存储不同的方式,但我只需要基本上是模拟的清除数据按钮,那会你会发现浏览到设置的管理应用程序一节中的应用程序时调用(即我只想走了所有的数据)。

我是一个Android小白和我在做最少的Java代码在这个项目上,所以我基本上是在寻找最简单的解决方案在这里。我想我可以定居在存储CURRENTVERSION到磁盘,然后经推出检查它每一次,看看是否的真正的当前版本中已写入磁盘的最后一个推出的版本相匹配。这是唯一的真正的方式来做到这一点?如果是这样,什么是这样做的最简单的方法是什么?

谢谢!

解决方案   

有没有办法强制应用程序的数据,自动在应用程序的更新清除?

没有,至少对我的定义自动。

  

我想我可以定居在存储CURRENTVERSION到磁盘,然后经推出检查它每一次,看看真正的当前版本被写入到​​磁盘上的最后一个推出的版本相匹配。这是唯一的真正的方式来做到这一点?

我将其命名为 lastKnownVersion ,但除此之外,这种做法似乎是合理而且可能是你唯一可行的选择。

  

如果是这样,什么是这样做的最简单的方法是什么?

嗯...你说什么。使用Java I / O(存储文件的地方里面getFilesDir())或共享preferences

记住,虽然,你的用户可能会,如果你在一个应用程序更新吹走他们的数据得到相当沮丧。就个人而言,我宁愿我们发现你原来的问题,更好的解决方案(我发现在一个特定的SDK,导致重新安装一个应用程序,它使用的SDK的新版本后,失败的一些Android手机中的错误 )。

So, I have found a bug in a specific sdk that causes it to fail on some Android phones after re-installing a new version of an app which uses the sdk (via adb install -r, and presumably when a user gets an update that has been pushed to the Android market). Is there any way to force an application's data to automatically be cleared upon update of the app? I realize there are different ways that data could be stored, but I just need to essentially simulate an invocation of the "Clear Data" button that'd you find when browsing to the application in the "Manage Applications" section of the Settings (i.e. I just want all data gone).

I am an Android noob and am doing minimal Java coding on this project, so I am basically looking for the simplest solution here. I suppose I could settle on storing a "currentVersion" to disk and then checking it upon launch every time to see if the real current version matches the version that was written to disk on the last launch. Is that the only real way to do this? If so, what's the simplest way to do so?

Thanks!

解决方案

Is there any way to force an application's data to automatically be cleared upon update of the app?

No, at least for my definition of "automatic".

I suppose I could settle on storing a "currentVersion" to disk and then checking it upon launch every time to see if the real current version matches the version that was written to disk on the last launch. Is that the only real way to do this?

I'd name it lastKnownVersion, but otherwise this approach seems sound and probably is your only viable option.

If so, what's the simplest way to do so?

Ummm...do exactly what you said. Use Java I/O (storing the file somewhere inside of getFilesDir()), or SharedPreferences.

Bear in mind, though, that your users may get rather frustrated if you blow away their data on an app update. Personally, I'd rather we find a better solution to your original problem ("I have found a bug in a specific sdk that causes it to fail on some Android phones after re-installing a new version of an app which uses the sdk").