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 { /** * Clears all messages. * * @param context The application context. * @return The number of messages cleared. */ public static int clearMessages(Context context) { SharedPreferences sp = context.getSharedPreferences("messages", Context.MODE_PRIVATE); int messages = sp.getInt("messages", 0); sp.edit().putInt("messages", 0).commit(); return messages; } }