Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.Activity;

import android.content.Context;

import android.content.SharedPreferences;

public class Main {

    public static String getLocalCache(Context ctx, String key) {
        if (ctx == null) {
            return null;
        }
        try {
            SharedPreferences sp = ctx.getSharedPreferences("LocalCache", Activity.MODE_PRIVATE);
            return sp.getString(key, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}