Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.os.Environment; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** * Writes file to external storage and returns the filename. * Writes as a JPEG file. * If you want to convert to a URI you need to prepend file:// * @param b * @param fileName * @return */ static public String saveImageToExternal(Bitmap b, String fileName) { //}, int width, int height) { FileOutputStream fos; String mypath = Environment.getExternalStorageDirectory() + "/" + fileName + ".jpg"; File file = new File(mypath); try { file.createNewFile(); fos = new FileOutputStream(file); // Use the compress method on the BitMap object to write image to the OutputStream b.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } ; return file.toString(); } }