Tuesday, 11 September 2012

Android, Create File

How to create Folder on External Memory in Android.

public boolean isExternalStorageWritable() {
  if (Environment.MEDIA_MOUNTED.equals(Environment
                        .getExternalStorageState()))
     return true;
   else
       return false;
   }

File folder;

if (isExternalStorageWritable()) {
      dbFolder = new File(
                    Environment.getExternalStorageDirectory()
                               + File.separator + "Mohammad");                
   }
  boolean success = false;
  if (!dbFolder.exists()) {
      success = dbFolder.mkdir();//one directory
// success = dbFolder.mkdir(); to create more than one directory 
//                        like "Mohammad/kaied/abuhmead"
  }
  if (!success) {
            DB_DIRE=null;
         }
  

Mohammad Abu Hmead

No comments:

Post a Comment