我正嘗試使用圖像文件創建文件夾。無法在Android中創建具有圖像的文件夾
這裏是代碼
File folder = new File(Environment.getExternalStorageDirectory().toString()+"/Aqeel/Images");
folder.mkdirs();
String extStorageDirectory = folder.toString();
File file = new File(extStorageDirectory, "Image2.PNG");
if(!folder.exists()){
Toast.makeText(MainActivity.this, "Not Exist", Toast.LENGTH_SHORT).show();
}
這裏是我的清單過於
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bernardo.hellow">
<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=".hello"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我已經添加了WRITE_EXTERNAL_STORAGE權限,但它仍然沒有工作。
什麼是 「不工作」 是什麼意思?你認爲它應該做什麼,它做什麼呢? –
@Bernardo D'Agostino你的targetSdk? – Nisarg
您必須得到SecurityException,請檢查! –