Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@choiboi
Created August 8, 2013 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choiboi/6188091 to your computer and use it in GitHub Desktop.
Save choiboi/6188091 to your computer and use it in GitHub Desktop.
/*
* Creates a new file path into the standard Android pictures directory.
*/
private String getOutputLink(String filename) {
String directory = "";
// Check if storage is mounted.
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
getResources().getString(R.string.app_name));
// Create the storage directory if it does not exist.
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
return null;
}
}
directory = mediaStorageDir.getPath() + File.separator + filename;
}
return directory;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment