Android Open Source - Android-Parse.com-GridView-Tutorial File Cache






From Project

Back to project page Android-Parse.com-GridView-Tutorial.

License

The source code is released under:

Apache License

If you think the Android project Android-Parse.com-GridView-Tutorial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.androidbegin.parsegridview;
/*  w w  w . j  a  v  a2s .  c o  m*/
import java.io.File;
import android.content.Context;

public class FileCache {

  private File cacheDir;

  public FileCache(Context context) {
    // Find the dir to save cached images
    if (android.os.Environment.getExternalStorageState().equals(
        android.os.Environment.MEDIA_MOUNTED))
      cacheDir = new File(
          android.os.Environment.getExternalStorageDirectory(),
          "ParseGridView");
    else
      cacheDir = context.getCacheDir();
    if (!cacheDir.exists())
      cacheDir.mkdirs();
  }

  public File getFile(String url) {
    String filename = String.valueOf(url.hashCode());
    // String filename = URLEncoder.encode(url);
    File f = new File(cacheDir, filename);
    return f;

  }

  public void clear() {
    File[] files = cacheDir.listFiles();
    if (files == null)
      return;
    for (File f : files)
      f.delete();
  }

}




Java Source Code List

com.androidbegin.parsegridview.FileCache.java
com.androidbegin.parsegridview.GridViewAdapter.java
com.androidbegin.parsegridview.ImageLoader.java
com.androidbegin.parsegridview.MainActivity.java
com.androidbegin.parsegridview.MemoryCache.java
com.androidbegin.parsegridview.ParseApplication.java
com.androidbegin.parsegridview.PhoneList.java
com.androidbegin.parsegridview.SingleItemView.java
com.androidbegin.parsegridview.Utils.java