Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.os.Environment;

import java.io.File;

public class Main {
    /**
     * Remove an album from the cache.
     * @param albumId Album ID
     */
    public static void removeAlbum(String albumId) {
        File albumDir = new File(getMusicCacheDir(), albumId);
        if (albumDir.exists()) {
            for (File file : albumDir.listFiles()) {
                file.delete();
            }
            albumDir.delete();
        }
    }

    /**
     * Returns the music cache directory.
     * @return Music cache directory
     */
    public static File getMusicCacheDir() {
        File music = Environment.getExternalStoragePublicDirectory("SismicsMusic");
        File cache = new File(music, "cache");
        if (!cache.exists()) {
            cache.mkdirs();
        }
        return cache;
    }
}