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 PREFERENCE_ID = "last_version";
    private static final String PREFERENCE_KEY = "should_show";

    public static boolean shouldShowDialog(String version, Context context) {
        String oldVersion = getSharedPreferences(context).getString(PREFERENCE_KEY, "");

        return !oldVersion.equalsIgnoreCase(version);
    }

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