Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.content.SharedPreferences;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<Integer> readSp(Context context, String key) {
        SharedPreferences sp = getSharedPreferences(context);
        List<Integer> result = new ArrayList<Integer>();
        String str = sp.getString(key, "");
        if (str.length() > 0) {
            String[] split = str.split(":");

            for (String string : split) {
                result.add(Integer.valueOf(string));
            }
        }
        return result;
    }

    public static SharedPreferences getSharedPreferences(Context context) {
        return context.getSharedPreferences("config", Context.MODE_PRIVATE);
    }
}