写文件的SD卡私下应用软件Android [英] writing file on sdcard privately for application android

查看:130
本文介绍了写文件的SD卡私下应用软件Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写的音频数据在SD卡AMR文件格式。

I am writing audio data as in amr file format in sdcard.

    File file = new File(dir, "test.amr");
    try {
        FileOutputStream f = new FileOutputStream(file);
        f.write(audioData);
        f.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    }

它正常工作,但我的问题是,它在其他应用程序中显示,以及像Android操作系统的默认媒体播放器。

Its working properly but my problem is it shows in other applications as well like in default media player of android OS.

我的问题是如何写SD卡一个文件,该文件是唯一能够给我application.Not到设备上的其他应用程序。

My question is how can write a file on sdcard which is only accessible to my application.Not to other applications on device.

感谢。

推荐答案

这是不可能的,在SD卡中的所有文件都可以访问到所有的应用程序。

That's not possible, all files on SD card are accessible to all apps.

要保持文件私有,在应用程序的本地目录中创建。 应用程序的私有文件夹的位置由以下因素决定:

To keep files private, create them in application's local directory. Location of app's private folder is determined by:

String dir = getPackageManager().getPackageInfo("com.example.app", 0).applicationInfo.dataDir;

其他选项:让空.nomedia的文件在SD卡上的文件夹,然后里面的文件就不会(也不应该)显示在媒体播放器

Other option: make empty ".nomedia" file in your folder on SD card, then files inside won't (should not) show in media players.

这篇关于写文件的SD卡私下应用软件Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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