将图像复制到内存

Ale*_*lex 3 android

我如何将图像复制到内部存储器并在此之后恢复?

Eli*_*ell 12

您可以使用openFileOutput()和Bitmap.compress()的以下组合将图像存储到内部存储.

// Create a BitMap object of the image to be worked with
final Bitmap bm = BitmapFactory.decodeStream( ..some image.. );

// The openfileOutput() method creates a file on the phone/internal storage in the context of your application 
final FileOutputStream fos = openFileOutput("my_new_image.jpg", Context.MODE_PRIVATE);

// Use the compress method on the BitMap object to write image to the OutputStream
bm.compress(CompressFormat.JPEG, 90, fos);
Run Code Online (Sandbox Code Playgroud)