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 android.preference.PreferenceManager;

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

public class Main {
    public static List<String> mDishLikeList = new ArrayList<>();

    public static void loadArray(Context mContext) {
        SharedPreferences mSharedPreference1 = PreferenceManager.getDefaultSharedPreferences(mContext);
        mDishLikeList.clear();
        int size = mSharedPreference1.getInt("Like_size", 0);

        for (int i = 0; i < size; i++) {
            mDishLikeList.add(mSharedPreference1.getString("Like_" + i, null));
        }
    }
}