Created
August 8, 2013 19:53
-
-
Save choiboi/6188091 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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