// Path: app/src/main/java/cn/bproject/neteasynews/Utils/MD5Encoder.java
// public static String hashKeyForDisk(String key) {
//     String cacheKey;
//     try {
//         final MessageDigest mDigest = MessageDigest.getInstance("MD5");
//         mDigest.update(key.getBytes());
//         cacheKey = bytesToHexString(mDigest.digest());
//     } catch (NoSuchAlgorithmException e) {
//         cacheKey = String.valueOf(key.hashCode());
//     }
//     return cacheKey;
// }


import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.util.Log;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import static cn.bproject.neteasynews.Utils.MD5Encoder.hashKeyForDisk;
package cn.bproject.neteasynews.Utils;




/**
 * Created by Administrator on 2016/12/8.
 * 设置本地缓存
 */

public class LocalCacheUtils {
    private static final String TAG = LocalCacheUtils.class.getSimpleName();

    /**
     * @param url     传入获取信息的网址，作为保存缓存的文件名
     * @param content 传入要缓存的信息
     */
    public static void setDiskLruCache(String url, String content) {
        Context context = UIUtils.getContext();
        DiskLruCache mDiskLruCache = null;
        try {
            File cacheDir = getDiskCacheDir(context, "news");
            if (!cacheDir.exists()) {
                cacheDir.mkdirs();
            }
            mDiskLruCache = DiskLruCache.open(cacheDir, getAppVersion(context), 1, 10 * 1024 * 1024);

// Path: app/src/main/java/cn/bproject/neteasynews/Utils/MD5Encoder.java
// public static String hashKeyForDisk(String key) {
//     String cacheKey;
//     try {
//         final MessageDigest mDigest = MessageDigest.getInstance("MD5");
//         mDigest.update(key.getBytes());
//         cacheKey = bytesToHexString(mDigest.digest());
//     } catch (NoSuchAlgorithmException e) {
//         cacheKey = String.valueOf(key.hashCode());
//     }
//     return cacheKey;
// }


// Path: app/src/main/java/cn/bproject/neteasynews/Utils/LocalCacheUtils.java
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.util.Log;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import static cn.bproject.neteasynews.Utils.MD5Encoder.hashKeyForDisk;

package cn.bproject.neteasynews.Utils;




/**
 * Created by Administrator on 2016/12/8.
 * 设置本地缓存
 */

public class LocalCacheUtils {
    private static final String TAG = LocalCacheUtils.class.getSimpleName();

    /**
     * @param url     传入获取信息的网址，作为保存缓存的文件名
     * @param content 传入要缓存的信息
     */
    public static void setDiskLruCache(String url, String content) {
        Context context = UIUtils.getContext();
        DiskLruCache mDiskLruCache = null;
        try {
            File cacheDir = getDiskCacheDir(context, "news");
            if (!cacheDir.exists()) {
                cacheDir.mkdirs();
            }
            mDiskLruCache = DiskLruCache.open(cacheDir, getAppVersion(context), 1, 10 * 1024 * 1024);

            String key = hashKeyForDisk(url);