I researched a lot on the internet but no use. I am very new to Android programming and java. I wrote a simple program in Android studio that lets you write a text in a cool font I set, optionally the user can chose color and font size. I want to save this text, with its font, font size, and font color; as an image viewable with any galley application. I tried lots of things spent hours on it but universe is still against me. I managed to create a bitmap image, and I can view it in an ImageView,but I can't save it to storage. Can someone please explain this very simply ? Im very new to both Android and Java.
Asked
Active
Viewed 979 times
1 Answers
-1
public boolean saveImageToInternalStorage(Bitmap image) {
try {
// Use the compress method on the Bitmap object to write image to
// the OutputStream
FileOutputStream fos = context.openFileOutput("desiredFilename.png", Context.MODE_PRIVATE);
// Writing the bitmap to the output stream
image.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
return true;
}
catch (Exception e) {
Log.e("saveToInternalStorage()", e.getMessage());
return false;
}
}

Jack Ryan
- 1,287
- 12
- 26