我正在使用路径"/mnt/sdcard/myfolder/myfile"
将我的文件存储在 android 应用程序中。当应用程序在没有任何 sdcard 插槽的手机(像 Nexus S 的手机)上运行时,它会给出任何错误吗?
问问题
144 次
2 回答
3
您必须检查外部存储是否可用
private static boolean isExternalStorageAvailable() {
String extStorageState = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(extStorageState)) {
return true;
}
return false;
}
于 2013-04-03T05:45:42.623 回答
2
请检查此链接:
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
mExternalStorageAvailable = mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// We can only read the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
} else {
// Something else is wrong. It may be one of many other states, but all we need
// to know is we can neither read nor write
mExternalStorageAvailable = mExternalStorageWriteable = false;
}
于 2013-04-03T05:49:45.953 回答