English 中文(简体)
如何在 sdcard 中创建私有文件夹
原标题:How to create private folder in sdcard

我的应用程序用于安全目的。 因此, 从我的应用程序用户捕捉照片中, 所有的照片都存储在文件夹中, 文件夹不应该从任何其他应用程序中访问, 而当设备连接到计算机系统时, 不应该给予访问权限。 如果用户想要查看这些图像, 他应该只访问我的应用程序 。

问题回答

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_ READADW、 MODE_ WORLD_ RWYITEB 。

AFAIK 的唯一途径是 < code> encrypt 您存储的文件。 无法阻止用户挂载 spdcard 访问存储的文件 。

根据这个相关的问题,您只能在内部存储(不是在SD上)中创建受保护的文件...

< a href=>> 创建无法为任何其他应用程序访问的文件夹

尝试以下解决方案 :

< a href=> https://stackoverflow.com/ questions/5482639/how-to-store- a-file- in-hidden-mode> 如何以隐藏模式存储文件

虽然这并不是你想要的,我怀疑它是否可行。 最好的选择是隐藏它,但同时也是有限制的(Linux而不是Windows的工作,还有其它应用程序可以访问文件夹)

< a href=> https://stackoverflow.com/ questions/8149103/how-to- hide- the- folder-of- sdcard- in-and-and-and-and-roid" > 如何将牌文件夹隐藏在和移动

"https://stackoverflow.com/ questions/112964/ how-to-make-a file-hidden- in-android-sd-card" 如何将文件隐藏在机器人牌中?

Its not possible to give no access to that folder when device connected to pc.. Also its not possible on sdcard also, But you can use different format for images that can be opened only from your application, or you can encrypt images. Or if you want to hide images from showing them into gallery, you can put a blank file with name as ".nomedia" in your folder. But its not possible cause if u read docs about WRITE_EXTERNEL_STORAGE permission you will understand what I am saying. :)





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签