3
我試圖在外部存儲器中創建一個文件夾,並且我在其中跟蹤了其他幾個線程。然而,儘管我似乎在做他們所表達的東西,但創作失敗了。無法在Android設備上的外部存儲器中創建文件夾
下面是一段代碼
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
mExternalStorageAvailable = true;
mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
} else {
mExternalStorageAvailable = false;
mExternalStorageWriteable = false;
}
File exst = Environment.getExternalStorageDirectory();
String exstPath = exst.getPath();
File fooo = new File(exstPath+"/fooo");
boolean success = fooo.mkdir();
當我執行它,我得到這個:
mExternalStorageAvailable = true;
mExternalStorageWriteable = true;
success = false;
這裏就是整個清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mydev.mobile.Test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<activity
android:label="@string/app_name"
android:name=".TestIndexSearchForHitsAndroidActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
什麼我做錯了嗎?謝謝!
Namari,由於很多它的工作!但是,你能向我解釋爲什麼以前它不工作嗎?在我使用的一些示例中,他們在''下有'WRITE_EXTERNAL_STORAGE'行,我認爲他們聲稱它有效。 –
http://developer.android.com/guide/topics/security/security.html – confucius