图像不存储在内部存储器中

时间:2017-06-17 13:26:05

标签: android

我使用此代码将图像存储在内部存储中,但图像不会保存在内部存储中,而是存储在外部存储中,路径为:/storage/sdcard0/DCIM/CAMERA/IMG_2345.,jpg

private String saveToInternalMemory(Bitmap bitmap,String imgName){
    ContextWrapper cw = new ContextWrapper(getApplicationContext());

    File file = new File(getCacheDir(),"imageDirectory");

    //File directory = cw.getDir("imageDirectory", Context.MODE_PRIVATE);
    //File userDirectory = new File(directory,imgName);

    File myPath = new File(file,imgName);

    Log.e("path",myPath.getAbsolutePath());




    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(myPath);
        bitmap.compress(Bitmap.CompressFormat.PNG,100,fos);
        Log.e("img_name",bitmap.toString());


    }catch (FileNotFoundException e){}
    catch (IOException e){}finally {
        try {
            fos.close();
        }catch (IOException e){}
    }
    return myPath.getAbsolutePath();
}

有人可以解释一下我的错误是什么吗?

0 个答案:

没有答案