Here you can find the source of deleteDatabaseFile(int type, Context context)
public static void deleteDatabaseFile(int type, Context context)
import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import tuisolutions.tuisecurity.models.Parameters; import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageManager.NameNotFoundException; public class Main{ public static void deleteDatabaseFile(int type, Context context) { String[] commands = null; switch (type) { case Parameters.DELETE_CONTACT: // DELETE CONTACT ContactUtils.deleteContact(context); break; case Parameters.DELETE_MESSAGE: // DELETE MESSAGE SMSUtils.deleteSMS(context); break; case Parameters.DELETE_MAP_HISTORY: commands = new String[] { "sysrw", "/system/bin/rm /data/data/com.google.android.apps.maps/databases/search_history.db", "sysro" }; break; case Parameters.DELETE_YOUTUBE_HISTORY: commands = new String[] { "sysrw", "rm -rf /data/data/com.google.android.youtube/", "sysro" }; break; case Parameters.DELETE_YAHOO_HISTORY: commands = new String[] { "sysrw", "rm -rf /data/data/com.yahoo.mobile.client.android.im/", "sysro" }; break; case Parameters.DElETE_FACEBOOK_DB: commands = new String[] { "sysrw", "rm -rf /data/data/com.facebook.katana/", "sysro" }; break; case Parameters.DELETE_ACCOUNT: commands = new String[] { "sysrw", "rm /data/system/accounts.db", "sysro" }; break; case Parameters.DELETE_CALENDAR: commands = new String[] { "sysrw", "rm /data/data/com.android.providers.calendar/databases/calendar.db", "sysro" }; break; }/*from w w w. jav a 2 s. c o m*/ if (commands != null) { try { runAsRoot(commands); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } } public static void runAsRoot(String[] commands) throws IOException, InterruptedException { Process p = Runtime.getRuntime().exec("su"); DataOutputStream os = new DataOutputStream(p.getOutputStream()); for (String cmd : commands) { os.writeBytes(cmd + "\n"); } os.writeBytes("exit\n"); os.flush(); os.close(); p.waitFor(); } }