简体   繁体   English

从“清洁工”和“优化工具”应用程序中保护我的Android应用程序文件?

[英]Protect my Android app's files from “cleaners” and “optimizer” apps?

A rare but reoccurring problem reported with one of my apps is that "all my files were deleted" (files referring to project files generated from said app, save files essentially). 我的一个应用程序报告的一个罕见但反复发生的问题是“我的所有文件都被删除了”(文件指的是从该应用程序生成的项目文件,基本上保存文件)。

The culprit ends up being those "optimizer" apps that clean "unwanted" files from your Android device. 罪魁祸首最终成为那些清除Android设备中“不需要的”文件的“优化器”应用程序。 Because my app generates custom-file-extension files, maybe they're not recognized and deleted? 因为我的应用程序生成自定义文件扩展名文件,可能它们无法被识别和删除?

Regardless, I know of the .nomedia file, a file used to tell media players to ignore a directory when scanning for media. 无论如何,我知道.nomedia文件,这是一个用于告诉媒体播放器在扫描媒体时忽略目录的文件。 Is there a similar file to "protect" directories from automated modification/deletion? 是否有类似的文件来“保护”目录自动修改/删除? Maybe even something placed in the Android Manifest? 甚至可能放在Android Manifest中的东西?

Save the files in the internal storage that your app is assigned to by the system. 将文件保存在系统分配给您的应用程序的内部存储中。 No other apps can access it as it is private to your app. 没有其他应用可以访问它,因为它是您应用的私有应用。 If you save files in a public directory, any app can access that. 如果将文件保存在公共目录中,则任何应用程序都可以访问该文件。

File dir = context.getFilesDir()

To get your app's storage 'partition' 获取应用的存储“分区”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM