Skip to content

Commit

Permalink
#19 #135 Attempting to create directories in SD card. Not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
hallahan committed Apr 9, 2016
1 parent b4e67ea commit bf5f680
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/src/main/java/org/redcross/openmapkit/ExternalStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ public class ExternalStorage {
* Creating the application directory structure.
*/
public static void checkOrCreateAppDirs() {
File externalDir = Environment.getExternalStorageDirectory();
File appDir = new File(externalDir, APP_DIR);

// NOTE: Unable to create directories in SD Card dir. Investigate further. #135
// File storageDir = getSDCardDirWithExternalFallback();

File storageDir = Environment.getExternalStorageDirectory();
File appDir = new File(storageDir, APP_DIR);
if(!appDir.exists()) {
appDir.mkdirs();
}
Expand Down Expand Up @@ -188,5 +192,15 @@ public static String[] getStorageDirectories() {
return dirs;
}

/**
* Use last storage dir, which is ext SD card. If there is no SD card,
* the last in the list will be the standard ext storage.
*
* @return storage dir
*/
public static File getSDCardDirWithExternalFallback() {
String[] dirs = getStorageDirectories();
return new File(dirs[dirs.length-1]);
}
}

0 comments on commit bf5f680

Please sign in to comment.