内部存储保存映像

时间:2020-02-16 17:53:58

标签: android

我想在内部存储器中保存一些图像。这是我的代码:

Bitmap bitmap = ((BitmapDrawable)iv_add.getDrawable()).getBitmap();
            File file = getApplicationContext().getDir("Images",MODE_PRIVATE);
            file = new File(file, "UniqueFileName"+".jpg");
            try{
                OutputStream stream = null;
                stream = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG,100,stream);
                stream.flush();
                stream.close();
            }catch (IOException e)
            {
                e.printStackTrace();
            }

据我了解,图片需要进入internal_storage / android / data / project_name / file。当我从图库中选择图片并单击按钮进行保存时,什么也没有发生,程序开始滞后。我该怎么办?

0 个答案:

没有答案