android emulator/eclipse 在重新部署时删除应用程序文件

标签 android eclipse emulation

我的应用程序从服务器下载文件并将其存储在: /mnt/sdcard/Android/data/com.test/files。 (/mnt/sdcard 派生自 Environment.getExternalStorageDirectory(); )

每次我将应用程序从 eclipse(运行菜单)重新部署到模拟器时,它都会删除该文件。 未选中运行配置中的复选框“目标/删除用户数据”。 我正确地关闭了所有 BufferedOutputStreams,所以我认为这不是我的应用程序本身。 我是否使用了正确的目录来存储持久数据? (我的文件大约有 70-100M)

有什么提示吗?

最佳答案

来自getExternalStorageDirectory's doc :

Applications should not directly use this top-level directory, in order to avoid polluting the user's root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir, which the system will take care of deleting if the application is uninstalled. Other shared files should be placed in one of the directories returned by getExternalStoragePublicDirectory(String).

您的 /mnt/sdcard/Android/data/com.test/files 应该在您的 Context.getExternalFilesDir() 中,当应用程序卸载时它会被删除.

关于android emulator/eclipse 在重新部署时删除应用程序文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3694055/

相关文章:

android - Phonegap 闪屏方向

java - 尝试连接并发送 telnet 命令时出现 NPE

java - 动态创建时出现新按钮上下文问题

eclipse - 在 eclipse 3.61 中尝试通过 updatesite 安装 google WindowMaker 时出现错误

emulation - Cloud Bigtable 是否有像 Cloud Datastore 这样的本地开发服务器?

android - RecyclerView 切断最后一项

java - android - Theme.Holo 与 DarkActionBar

java - 我在使用 "else if"语句时遇到错误。

Android模拟器Jenkins插件不起作用

ios - 智能脸 4.3.0。 IOS 模拟器错误