Java tutorial
//package com.java2s; //License from project: Open Source License import android.os.Environment; import java.io.File; import java.io.FilenameFilter; import java.util.HashSet; import java.util.Set; public class Main { /** * Returns album IDs containing at least one cached track. * @return Albums IDs */ public static Set<String> getCachedAlbumSet() { File cacheDir = getMusicCacheDir(); File[] albumList = cacheDir.listFiles(); Set<String> output = new HashSet<>(); for (File album : albumList) { if (album.list(new FilenameFilter() { @Override public boolean accept(File dir, String filename) { return filename.endsWith(".complete"); } }).length > 0) { output.add(album.getName()); } } return output; } /** * 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; } }