Skip to content

Instantly share code, notes, and snippets.

@SyncHack
Created March 3, 2012 10:14
Show Gist options
  • Save SyncHack/1965375 to your computer and use it in GitHub Desktop.
Save SyncHack/1965375 to your computer and use it in GitHub Desktop.
File getTrueExternalStorageDirectory() {
final File standard = Environment.getExternalStorageDirectory();
// SUMSUNG製品が他のどの製品よりも優れた独自仕様
final File sd = new File(standard, "sd");
final File ext = new File(standard, "external_sd");
if (sd.exists() && sd.isDirectory())
return sd;
else if (ext.exists() && ext.isDirectory())
return ext;
return standard;
}
@SyncHack
Copy link
Author

SyncHack commented Mar 3, 2012

元ネタ
http://toro.2ch.net/test/read.cgi/tech/1321864986/834
Androidプログラミング質問スレ Part15

このコードで通用するのはせいぜいAndroid 2.3.xまででAndroid 3.x以上だと厳しいと思われ。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment