存储没有获得更新或卸载删除Android上的文件 [英] Storing Files on Android that don't get deleted on update or uninstall

查看:121
本文介绍了存储没有获得更新或卸载删除Android上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要一些数据存储在Android设备上的文件(而不是数据库)。目前我使用Context.getFileDir()的父目录。但是,当您更新目录中被删除的应用程序。是否有一个目录,当用户去更新应用程序,我可以从上下文不会得到wacked使用?它必须是SD卡,因为这并不总是普遍适用于所有的手机呢?

I want to store some data to a File (not database) on the Android device. Currently I'm using Context.getFileDir() as the parent directory. However, when you update the app that directory gets deleted. Is there a directory I can use from Context that won't get wacked when the user goes to update the application? Does it have to be the SD Card since that's not always generally available on all phones?

推荐答案

如果您想要的文件不要在卸载删除是不可能的,因为ü可能b knw THT卸载将删除所有数据。

If you want to file not to be deleted on uninstall is not possible as u might b knw tht uninstall will delete all the data.

而如果你想节省$ C $的更新文件c奥尤可以因为你是通过创建getFileDir()文件中使用使用THT同样的方法,只是你必须检查每一次B4创建,如果文件的文件THT已经存在与否

While if you want to save the file on update of code Oyu can use tht same method as you are using by creating file on getFileDir();just you have to check out each time b4 creating file tht if file already exists or not

如果文件exixts THR是没有必要再创造,如果没有那朵THR THN创建它。

if file exixts thr is no need to create again and if it tis not thr thn create it.

我假设THT你做了文件中创建正确的全体员工。

i am assuming tht you have done all stuff of file creating properly.

只是添加下面code B4创建它。

just add below code b4 creating it.

if(f.exists()) //Where f is your file
{
    //Don't create the file, it already exists
}
else{
    //Create the file, since it didn't exist
}

这篇关于存储没有获得更新或卸载删除Android上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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