public static File getRootStorageDirectory(Context c, String directory_name){
        File result;
        // First, try getting access to the sdcard partition
        if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
            Log.d(TAG,"Using sdcard");
            result = new File(Environment.getExternalStorageDirectory(), directory_name);
        } else {
            // Else, use the internal storage directory for this application
            Log.d(TAG,"Using internal storage");
            result = new File(c.getApplicationContext().getFilesDir(), directory_name);
        }

        if(!result.exists())
            result.mkdir();
        else if(result.isFile()){
            return null;
        }
        Log.d("getRootStorageDirectory", result.getAbsolutePath());
        return result;
    }
public static File getRootStorageDirectory ( Context c , String directory_name ) { File result ; if ( Environment . getExternalStorageState ( ) . equals ( Environment . MEDIA_MOUNTED ) ) { Log . d ( TAG , "Using sdcard" ) ; result = new File ( Environment . getExternalStorageDirectory ( ) , directory_name ) ; } else { Log . d ( TAG , "Using internal storage" ) ; result = new File ( c . getApplicationContext ( ) . getFilesDir ( ) , directory_name ) ; } if ( ! result . exists ( ) ) result . mkdir ( ) ; else if ( result . isFile ( ) ) { return null ; } Log . d ( "getRootStorageDirectory" , result . getAbsolutePath ( ) ) ; return result ; }
Returns a Java File initialized to a directory of given name
at the root storage location, with preference to external storage.
If the directory did not exist, it will be created at the conclusion of this call.
If a file with conflicting name exists, this method returns null;

@param c the context to determine the internal storage location, if external is unavailable
@param directory_name the name of the directory desired at the storage location
@return a File pointing to the storage directory, or null if a file with conflicting name
exists