Code example for LruCache

0
import vietnamese.com.android.inputmethod.latin.R; 
 
public class TargetApplicationGetter extends AsyncTask<String, Void, ApplicationInfo> {
 
    private static final int MAX_CACHE_ENTRIES = 64; // arbitrary
    private static LruCache<String, ApplicationInfo> sCache =
            new LruCache<String, ApplicationInfo>(MAX_CACHE_ENTRIES);
 
    public static ApplicationInfo getCachedApplicationInfo(final String packageName) {
        if (null == packageName) return null;
        return sCache.get(packageName);
    } 
    public static void removeApplicationInfoCache(final String packageName) {
        sCache.remove(packageName);
    } 
 
    public interface OnTargetApplicationKnownListener { 
        public void onTargetApplicationKnown(final ApplicationInfo info);
    } 
 
    private Context mContext;