Java tutorial
//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 final String SLOT_TAG = "id"; public static final String TITLE_TEXT_TAG = "titletext"; public static final String MESSAGE_BODY_TEXT_TAG = "messagetext"; public static final String UTC_SCHEDULED_TIME = "scheduledtime"; public static final String REPEAT_TIME = "repeattime"; public static void writePreference(Context context, int slot, String title, String message, Long alertTime, int repeat) { SharedPreferences.Editor editor = getNotificationSettings(context, slot).edit(); if (editor == null) { Log.i(TAG, "Failed to write notification to preferences"); return; } editor.putInt(SLOT_TAG, slot); editor.putString(TITLE_TEXT_TAG, title); editor.putString(MESSAGE_BODY_TEXT_TAG, message); editor.putLong(UTC_SCHEDULED_TIME, alertTime); editor.putInt(REPEAT_TIME, repeat); boolean committed = editor.commit(); if (!committed) { Log.i(TAG, "Failed to write notification to 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::"; } }