我有一个位图,我想将它保存到应用程序文件夹。我尝试使用以下代码:
ContextWrapper contextWrapper = new ContextWrapper(context.getApplicationContext());
File directory = contextWrapper.getDir("tabs", Context.MODE_PRIVATE);
if (!directory.exists())
directory.mkdir();
String fname = "Image.jpg";
File file = new File(directory, fname);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, fos);
fos.close();
} catch (Exception e) {
Log.e("SAVE_IMAGE", e.getMessage(), e);
}
现在,我有两个问题。
- 为什么会出现这个警告并如何修复它?
'File.mkdir()'的结果被忽略了
- 文件夹“app_tabs”已创建在应用程序文件夹中,但未保存位图,并且文件夹中没有照片。如何保存此位图?