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;

public class Main {
    private static final String WEATHER_PREFERENCES = "DilyWeatherPreferences";
    public static final String PREFERENCE_LOCAL = WEATHER_PREFERENCES + ".local";

    public static void writeLocal(Context context, String local) {
        SharedPreferences.Editor editor = getEditor(context);
        editor.putString(PREFERENCE_LOCAL, local);
        editor.apply();
    }

    private static SharedPreferences.Editor getEditor(Context context) {
        SharedPreferences preferences = getSharedPreferences(context);
        return preferences.edit();
    }

    private static SharedPreferences getSharedPreferences(Context context) {
        return context.getSharedPreferences(WEATHER_PREFERENCES, Context.MODE_PRIVATE);
    }
}