Java tutorial
//package com.java2s; /** * Copyright (c) 2014 Microsoft Mobile and/or its subsidiary(-ies). * See the license text file delivered with this project for more information. */ import android.content.Context; import android.content.SharedPreferences; public class Main { /** * Stores the given message. * * @param context The application context. * @param message The message to store. * @return The number of total message including the stored one. */ public static int storeMessage(Context context, String message) { SharedPreferences sp = context.getSharedPreferences("messages", Context.MODE_PRIVATE); int messages = sp.getInt("messages", 0) + 1; sp.edit().putInt("messages", messages).putString("last", message).commit(); return messages; } }