Created
January 10, 2011 11:33
-
-
Save christoph-jerolimov/772667 to your computer and use it in GitHub Desktop.
Load Android SDCard Folder for different devices (Android Standard, Samsung Galaxy S, HTC Incredible)
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
private String getSdcardFolder() { | |
File externalStorage = Environment.getExternalStorageDirectory(); | |
if (externalStorage.exists() && externalStorage.canWrite()) { | |
File trySubDir1 = new File(externalStorage, "external_sd"); | |
File trySubDir2 = new File(externalStorage, "sd"); | |
if (trySubDir1.exists() && trySubDir1.canWrite()) { | |
return trySubDir1.getAbsolutePath(); | |
} else if (trySubDir2.exists() && trySubDir2.canWrite()) { | |
return trySubDir2.getAbsolutePath(); | |
} else { | |
return externalStorage.getAbsolutePath(); | |
} | |
} | |
String[] tryOtherSubDirs = new String[] { | |
"/sdcard/external_sd", | |
"/sdcard/sd", | |
"/mnt/sdcard/external_sd", | |
"/mnt/sdcard/sd", | |
"/mnt/sdcard" | |
}; | |
for (String trySubDir : tryOtherSubDirs) { | |
File dir = new File(trySubDir); | |
if (dir.exists() && dir.canWrite()) { | |
return dir.getAbsolutePath(); | |
} | |
} | |
return "/sdcard"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment