bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
if(android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
{
cacheFile = new File(android.os.Environment.getExternalStorageDirectory(), "Android/data/"+this.getPackageName()+"/cache/");
if(!cacheFile.exists())
{
cacheFile.mkdir();
}
try {
fileOutputStream = new FileOutputStream(cacheFile);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
Log.i("Error", e.getMessage());
}
}
但我收到 mnt/sdcard/Android/data/com.android.linegame/cache 文件不存在的错误