Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;

import android.content.Context;

public class Main {
    /**
     * Enable HTTP response cache, available from Android 4.0 onward, using reflection.
     */
    static void enableHttpResponseCache(Context context, long cacheSize) {
        try {
            File httpCacheDir = new File(context.getCacheDir(), "http");
            Class.forName("android.net.http.HttpResponseCache").getMethod("install", File.class, long.class)
                    .invoke(null, httpCacheDir, cacheSize);
        } catch (Exception httpResponseCacheNotAvailable) {
            // Do nothing, user is using a version prior to 4.0
        }
    }
}