Code example for File

Methods: getParent

0
    } 
 
    private static File getAlbumDirectory(Context context, MusicDirectory.Entry entry) {
        File dir;
        if (entry.getPath() != null) {
            File f = new File(fileSystemSafeDir(entry.getPath()));
            dir = new File(getMusicDirectory(context).getPath() + "/" + (entry.isDirectory() ? f.getPath() : f.getParent()));
        } else { 
            String artist = fileSystemSafe(entry.getArtist());
            String album = fileSystemSafe(entry.getAlbum());
            dir = new File(getMusicDirectory(context).getPath() + "/" + artist + "/" + album);
        } 
        return dir;
    } 
 
    public static void createDirectoryForParent(File file) {
        File dir = file.getParentFile();
        if (!dir.exists()) {
            if (!dir.mkdirs()) {
                Log.e(TAG, "Failed to create directory " + dir);
            }