我想获得内部手机存储文件以及SD卡文件...但我没有得到任何方法来执行此操作这是我获取外部存储目录的代码
String root = Environment.getExternalStorageDirectory().toString();
这是函数
private void getAllFilesOfDir(File directory) {
Log.d(TAG, "Directory: " + directory.getAbsolutePath() + "\n");
final File[] files = directory.listFiles();
if ( files != null ) {
for ( File file : files ) {
if ( file != null ) {
if (file.isDirectory() ) { // it is a folder...
getAllFilesOfDir(file);
}
else { // it is a file...
myList.add( file.getAbsolutePath() + "\n");
}
}
}
}
但是我希望从手机存储文件获得任何帮助,请????
答案 0 :(得分:0)
要检查设备是否具有内部存储,外部存储或两者,请使用:
if (Environment.MEDIA_MOUNTED.equals(state)) {
mExternalStorageAvailable = mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
} else {
mExternalStorageAvailable = mExternalStorageWriteable = false;
}
if (mExternalStorageAvailable) {
File path = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath()
+ "/EMD Systems/Append");
if (!path.exists()) {
path.mkdirs();
}
f = path;
} else {
File dir1 = getApplicationContext().getDir("EMD Systems", Context.MODE_PRIVATE);
File dir = new File(dir1 + "/Append");
if (!dir.exists()) {
dir.mkdirs();
}
f = dir;
}