user1951072 user1951072 - 1 year ago 157
Android Question

android mkdirs in SD card return me, it spends me 3days

I want to create a folder in SD card ,and i already add the permission

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

in manifest file.below is my code,but mkdirs return false! Can you help me!

File exportDir = new File(
Environment.getExternalStorageDirectory().toString(), "happydiarybackup");
if (!exportDir.exists()) {
boolean a = exportDir.mkdirs();
Log.d("mkdir ",exportDir.getAbsolutePath() + " make "+ a);

Answer Source

Try this. It might help you.

String fullPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/happydiarybackup/";
    File dir = new File(fullPath);
    if (!dir.exists()) {
 catch (Exception e) {
   Log.e("App", "Exception" + e.getMessage());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download