Ho can i delete all data(clear data) of all applications installed in my android device?
link bellow :
http://stackoverflow.com/questions/19830706/kill-another-application-and-clear-its-data
converted to C# android xamarin!
` public static void DeleteAllApps(Context _context)
{
Intent mainIntent = new Intent(Intent.ActionMain, null);
mainIntent.AddCategory(Intent.CategoryLauncher);
IList<Android.Content.PM.ResolveInfo> pkgAppsList = _context.PackageManager.QueryIntentActivities(mainIntent, 0);
for (int i = 0; i < pkgAppsList.Count; i++)
{
try
{
ActivityManager activityManager = (ActivityManager)_context.GetSystemService(Context.ActivityService);
activityManager.KillBackgroundProcesses(pkgAppsList[i].ResolvePackageName);
clearApplicationData(pkgAppsList[i].ResolvePackageName, _context);
} catch(Exception ex) { } } } static void clearApplicationData(String packageName, Context _context) { File cache = _context.CacheDir; File appDir1 = new File(cache.Parent).ParentFile; File appDir = new File(appDir1.AbsolutePath + "/" + packageName); if (appDir.Exists()) { String[] children = appDir.List(); foreach (string s in children) { if (!s.Equals("lib")) { deleteDir(new File(appDir, s)); } } } } static bool deleteDir(File dir) { if (dir != null && dir.IsDirectory) { String[] children = dir.List(); for (int i = 0; i < children.Length; i++) { bool success = deleteDir(new File(dir, children[i])); if (!success) { return false; } } } return dir.Delete(); }`