简体   繁体   中英

mkdirs not working in android studio avd

I am using Android studio 2.3.3. when use USB Device directory is created. But in emulator no directory is created.

Code:

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");
}

And in my Android.Manifest.xml I have

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

And 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

在模拟器设备中,转到设置->应用->您的应用->权限,然后启用存储

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM