public static String writeImage(Context ctx,byte[] imageData){
  final String FILE_NAME="photograph.jpeg";
  File dir=null;
  String filePath=null;
  OutputStream imageFileOS;
  dir=getStorageDirectory(ctx,null);
  File f=new File(dir,FILE_NAME);
  try {
    imageFileOS=new FileOutputStream(f);
    imageFileOS.write(imageData);
    imageFileOS.flush();
    imageFileOS.close();
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  Exception e) {
    e.printStackTrace();
  }
  filePath=f.getAbsolutePath();
  return filePath;
}

public static String writeImage ( Context ctx , byte [ ] imageData ) { final String FILE_NAME = "photograph.jpeg" ; File dir = null ; String filePath = null ; OutputStream imageFileOS ; dir = getStorageDirectory ( ctx , null ) ; File f = new File ( dir , FILE_NAME ) ; try { imageFileOS = new FileOutputStream ( f ) ; imageFileOS . write ( imageData ) ; imageFileOS . flush ( ) ; imageFileOS . close ( ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } filePath = f . getAbsolutePath ( ) ; return filePath ; }
writes the given image to the external storage of the device . if external storage is not available , the image is written to the application private directory
