我试图创建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并请告诉您的操作系统版本 –