Skip to content

Commit

Permalink
Use photos directory to store photos.
Browse files Browse the repository at this point in the history
Currently the sample demonstrates storing images in the root
of the external storage. It may be useful to demonstrate having
a directory where a developer can store their files.

Change-Id: I5c51df40c630271f763315f6a694f01e8a4b9f5c
  • Loading branch information
kroikie committed Jul 29, 2016
1 parent d3c3e55 commit 5a46d81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,13 @@ private void launchCamera() {
}

// Choose file storage location, must be listed in res/xml/file_paths.xml
File file = new File(Environment.getExternalStorageDirectory(),
UUID.randomUUID().toString() + ".jpg");
File dir = new File(Environment.getExternalStorageDirectory() + "/photos");
File file = new File(dir, UUID.randomUUID().toString() + ".jpg");
try {
// Create directory if it does not exist.
if (!dir.exists()) {
dir.mkdir();
}
boolean created = file.createNewFile();
Log.d(TAG, "file.createNewFile:" + file.getAbsolutePath() + ":" + created);
} catch (IOException e) {
Expand Down
2 changes: 1 addition & 1 deletion storage/app/src/main/res/xml/file_paths.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="external" path="." />
<external-path name="external" path="photos/" />
</paths>

0 comments on commit 5a46d81

Please sign in to comment.