Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import java.io.File; public class Main { public static void deleteSharedPreferences(Context context) { try { Context appContext = context.getApplicationContext(); ApplicationInfo info = appContext.getPackageManager().getApplicationInfo(appContext.getPackageName(), 0); String dirPath = info.dataDir + File.separator + "shared_prefs" + File.separator; File dir = new File(dirPath); if (dir.exists() && dir.isDirectory()) { String[] list = dir.list(); int size = list.length; for (int i = 0; i < size; i++) { new File(dirPath + list[i]).delete(); } } else { //Log.d("AAA", "NO FILE or NOT DIR"); } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } } }