我想将位图图像存储在内部存储(而不是外部存储)上。我已经编写了这段代码,但似乎有问题。因为当我从 DDMS 下载图像时,我无法打开它。
public String writeFileToInternalStorage(Context context, Bitmap outputImage) {
String fileName = Long.toString(System.currentTimeMillis()) + ".png";
try {
OutputStreamWriter osw = new OutputStreamWriter(context.openFileOutput(fileName, Context.MODE_PRIVATE));
osw.write(outputImage.toString());
Log.i(TAG, "Image stored at: " + fileName);
} catch (Exception e) {
Log.w(TAG, e.toString());
fileName = null;
}
return fileName;
}