0

我正在使用Android studio 2.3.3。當使用USB Device目錄創建時。但是在模擬器中沒有創建目錄。mkdirs不能在android studio中工作avd

代碼:

String SDK= Environment.getExternalStorageDirectory().getAbsolutePath(); 
String DB=SDK+"/MathEdu/DataBase"; 

File file=new File(DB); 

file.mkdirs(); 
if (file.exists()){ 
    Log.i("log", "exists"); 
} else{ 
    Log.i("log", "not exists"); 
} 

在我Android.Manifest.xml我有

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

而且logcat的:

10-05 06:43:23.145 3001-3001/? I/art: Not late-enabling -Xcheck:jni (already on) 
10-05 06:43:23.145 3001-3001/? W/art: Unexpected CPU variant for X86 using defaults: x86 
10-05 06:43:23.197 3001-3001/ir_100110.mathedu W/System: ClassLoader 
referenced unknown path: /data/app/ir_100110.mathedu-1/lib/x86 

                [ 10-05 06:43:23.208 
1834: 2021 D/   ] 
                HostConnection::get() 
New Host Connection established 0x94a83fc0, tid 2021 
10-05 06:43:23.240 3001-3001/ir_100110.mathedu W/art: Before Android 4.1, 
method android.graphics.PorterDuffColorFilter 
android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 
10-05 06:43:24.191 3001-3016/ir_100110.mathedu I/OpenGLRenderer: Initialized EGL, version 1.4 
10-05 06:43:24.191 3001-3016/ir_100110.mathedu D/OpenGLRenderer: Swap behavior 1 
10-05 06:43:24.191 3001-3016/ir_100110.mathedu W/OpenGLRenderer: Failed to 
choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 
10-05 06:43:24.191 3001-3016/ir_100110.mathedu D/OpenGLRenderer: Swap behavior 0 
10-05 06:43:26.875 3001-3001/ir_100110.mathedu I/log: not exists 

回答

0

在模擬器設備去 設置 - >應用程式 - >您的應用程式- >許可 然後啓用存儲