public static long writeFile(String path,byte[] jpeg,ExifInterface exif) throws IOException {
  if (!createDirectoryIfNeeded(path)) {
    Log.e(TAG,"Failed to create parent directory for file: " + path);
    return -1;
  }
  if (exif != null) {
    exif.writeExif(jpeg,path);
    File f=new File(path);
    return f.length();
  }
 else {
    return writeFile(path,jpeg);
  }
}

public static long writeFile ( String path , byte [ ] jpeg , ExifInterface exif ) throws IOException { if ( ! createDirectoryIfNeeded ( path ) ) { Log . e ( TAG , "Failed to create parent directory for file: " + path ) ; return - 1 ; } if ( exif != null ) { exif . writeExif ( jpeg , path ) ; File f = new File ( path ) ; return f . length ( ) ; } else { return writeFile ( path , jpeg ) ; } }
writes the jpeg data to a file . if there ' s exif info , the exif header will be added .
