public static void writeFile (File photo, double latitude, double longitude) throws IOException{ ExifInterface exif = null; try{ Log.v("latiDouble", ""+latitude); Log.v("longiDouble", ""+longitude); exif = new ExifInterface(photo.getCanonicalPath()); if (exif != null) { double latitu = latitude; double longitu = longitude; double alat = Math.abs(latitu); double along = Math.abs(longitu); String stringLati = convertDoubleIntoDegree(alat); String stringLongi = convertDoubleIntoDegree(along); exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, stringLati); exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, stringLongi); Log.v("latiString", ""+ stringLati); Log.v("longiString", ""+ stringLongi); exif.saveAttributes(); String lati = exif.getAttribute (ExifInterface.TAG_GPS_LATITUDE); String longi = exif.getAttribute (ExifInterface.TAG_GPS_LONGITUDE); Log.v("latiResult", ""+ lati); Log.v("longiResult", ""+ longi); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
I copied the answer from here