Android以私人模式将照片保存在磁盘上 [英] Android save photo on disk in private mode

查看:94
本文介绍了Android以私人模式将照片保存在磁盘上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用:将图像保存在磁盘中

I'm able to save a Image in disk using :

String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath();
        String fileName = imageId + ".png";
        String filePath = baseDir + File.separator + fileName;

        File file = new File(filePath);
        if(!file.exists())
        {
            out = new FileOutputStream(baseDir + File.separator + fileName);
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
        }

但是所有保存的图像都可以在手机的图库中看到..如何将其隐藏给用户?是否有我的私人文件夹?

But all the images saved are visible in the gallery of the phone .. How can I hide them to the user ? Is there a private folder for my appliaction ?

谢谢

推荐答案

public File getAlbumStorageDir(Context context, String albumName) {
    // Get the directory for the app's private pictures directory. 
    File file = new File(context.getExternalFilesDir(
            Environment.DIRECTORY_PICTURES), albumName);
    if (!file.mkdirs()) {
        Log.e(LOG_TAG, "Directory not created");
    }
    return file;
}

我想这就是你想要的.阅读 https://developer.android.com/training/basics/有关更多信息,请访问data-storage/files.html#WriteExternalStorage .

I think this is what you want. Read https://developer.android.com/training/basics/data-storage/files.html#WriteExternalStorage for more information.

这篇关于Android以私人模式将照片保存在磁盘上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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