我想在内部存储器中保存一些图像。这是我的代码:
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。当我从图库中选择图片并单击按钮进行保存时,什么也没有发生,程序开始滞后。我该怎么办?