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 { /** * Pops the latest message from the messages and returns it. * * @param context The application context. * @return The latest message. */ public static String popLastMessage(Context context) { SharedPreferences sp = context.getSharedPreferences("messages", Context.MODE_PRIVATE); String last = sp.getString("last", null); sp.edit().putString("last", null).commit(); return last; } }