Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;

public class Main {
    private static final String KEY_ACCOUNT_NAME = "account_name";
    private static String mCurrentUser = null;

    @TargetApi(Build.VERSION_CODES.GINGERBREAD)
    public static void removeAccount(Context ctx) {
        SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(ctx).edit();
        editor.remove(KEY_ACCOUNT_NAME);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
            editor.apply();
        } else {
            editor.commit();
        }
        mCurrentUser = null;
    }
}