希望对你有帮助
private static void persistImage(Bitmap bitmap, String name) { File filesDir = getAppContext().getFilesDir(); File imageFile = new File(filesDir, name + ".jpg"); OutputStream os; try { os = new FileOutputStream(imageFile); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os); os.flush(); os.close(); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Error writing bitmap", e); } }