Code example for String

Methods: getExternalStoragePublicDirectory

0
        return m_orientationListener.deviceOrientation;
    } 
 
    static String getDefaultMediaDirectory(int type)
    { 
        String dirType = new String();
        switch (type) {
            case 0: 
                dirType = Environment.DIRECTORY_MUSIC;
                break; 
            case 1: 
                dirType = Environment.DIRECTORY_MOVIES;
                break; 
            case 2: 
                dirType = Environment.DIRECTORY_DCIM;
                break; 
            default: 
                break; 
        } 
 
        File path = new File("");
        if (type == 3) {
            // There is no API for knowing the standard location for sounds 
            // such as voice recording. Though, it's typically in the 'Sounds' 
            // directory at the root of the external storage 
            path = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
                            + File.separator + "Sounds");
        } else { 
            path = Environment.getExternalStoragePublicDirectory(dirType);
        } 
 
        path.mkdirs(); // make sure the directory exists
 
        return path.getAbsolutePath();