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.content.Context;

import android.content.SharedPreferences;

import android.util.Log;

public class Main {
    public static final String TAG = "LocalNotifications";

    public static void erasePreference(Context context, int slot) {
        SharedPreferences.Editor editor = getNotificationSettings(context, slot).edit();
        if (editor == null) {
            Log.i(TAG, "Failed to erase notification from preferences");
            return;
        }
        editor.clear();
        boolean committed = editor.commit();

        if (!committed) {
            Log.i(TAG, "Failed to erase notification from preferences");
        }
    }

    public static SharedPreferences getNotificationSettings(Context context, int slot) {
        return context.getSharedPreferences(getNotificationName(slot), Context.MODE_WORLD_READABLE);
    }

    public static String getNotificationName(int slot) {
        return getPackageName() + ".Notification" + slot;
    }

    public static String getPackageName() {
        return "::APP_PACKAGE::";
    }
}