Create a temporary file to see whether a volume on External Storage is really writeable - Android android.os

Android examples for android.os:External Storage

Description

Create a temporary file to see whether a volume on External Storage is really writeable

Demo Code

import java.io.File;

import android.os.Environment;

public class Main {

   static boolean checkFsWritable() {

    String directoryName = Environment.getExternalStorageDirectory().toString() + "/DCIM";
    File directory = new File(directoryName);
    if (!directory.isDirectory()) {
      if (!directory.mkdirs()) {
        return false;
      }//from   w  ww.ja  v  a  2  s . c o  m
    }
    return directory.canWrite();
  }

}

Related Tutorials