我使用此代码将图像存储在内部存储中,但图像未保存在手机存储中,而是存储在SD卡中,路径为:/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();
}
手机存储和内存是否相同? 实际上,当我删除我的SD卡时,图像存储在手机存储中,但如果我重新连接我的SD卡,那么默认情况下它存储在SD卡中。如何将我的图像默认存储在手机存储中。 我们的android的文件存储显示两个目录SD卡和手机存储,因此图像存储在SD卡中而不是存储在手机存储中