我試圖創建Android的SD卡的文件夾......對於我在清單文件添加許可,而我這是我的代碼..聯想不允許在SD卡上創建文件夾
public void createFile(View view)
{
String state= Environment.getExternalStorageState();
if(Environment.MEDIA_MOUNTED.equals(state)){
File wallpaperDirectory = new File("/sdcard/Wallpaper/");
res=wallpaperDirectory.mkdir()
if(res){
Toast.makeText(this, "Success", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show();
}
}
else{
Toast.makeText(this, "Make sure that you have a memory card mounted...", Toast.LENGTH_SHORT).show();
}
}
當我運行相同的代碼在奇巧模擬器其創建文件夾,但提前履行了聯想總是說失敗...謝謝...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bk.acs">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SubActivity1"></activity>
</application>
</manifest>
你已在設備中的SD卡 –
是的,我有..如果我沒有SD卡,那麼它應該給土司爲確保等等等等.. – bharath
可以顯示您menifest並請告訴您的操作系統版本 –