如何创建私有文件夹在SD卡夹在、文件、SD

2023-09-05 02:23:22 作者:不想活又不敢死等数载

我的应用程序用于安全目的。所以,从我的应用程序用户捕获所有的照片都保存在该文件夹不应该从任何其他应用程序访问,不应该给访问时,设备连接到计算机系统中的文件夹中的照片。如果用户要查看这些图片,他应该从我的应用程序只能访问。

My application is used for security purpose. so, from my application user captures photos that all photos are stored in a folder that folder should not access from any other application and should not give access when devices connect to computer system. If user wants to view these images he should access only from my application.

谁能plaese帮我......

can anyone plaese help me......

在此先感谢

推荐答案

根据这一指南,您可以直接保存在设备的内部存储的文件。默认情况下,保存在内部存储的文件是私有的,你的应用程序和其他应用程序不能访问这些文件(也不能在用户)。当用户卸载应用程序,这些文件将被删除。 例如:

According to this guide, you can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed. For example:

String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();

MODE_PRIVATE将创建文件(或替换同名文件),并使其专用于您的应用程序。其它可用的模式有:MODE_APPEND,MODE_WORLD_READABLE和MODE_WORLD_WRITEABLE

MODE_PRIVATE will create the file (or replace a file of the same name) and make it private to your application. Other modes available are: MODE_APPEND, MODE_WORLD_READABLE, and MODE_WORLD_WRITEABLE.