By Phillip


2015-08-06 14:21:50 8 Comments

I don't like having my searches and web history hanging around forever. Therefore, I wonder: Is it possible to automatically clear browsing data on exit in Google Chrome? If it cannot be done with Chrome, do you know of any other good web browsers with this capability?

P.S. I am not willing to root my device just for this purpose. Therefore, I'm looking for a solution which does not require root access.

3 comments

@Firelord 2015-08-06 21:21:16

It's not possible with Chrome on a non-rooted device unless an app has access to Chrome's data directory, which could be the case if that app is owned by Google, or it's a Chrome plugin. Both type of apps doesn't exist as of now. So the short answer i.e. without root access, would be NO, you can't automatically clear browsing data on exit in Chrome for Android.


That said, somebody owning a rooted device may come looking for an answer in future. Here we go with a solution!

Note that this solution is reached by Trial and error. I experimented something and it seemed to work perfectly on my devices running Android 4.2.1, 4.4.2 and 5.0.2, and using Chrome v43.0.2357.93, which means I don't claim any knowledge of what the files (mentioned below) actually do or are used for.

About Chrome's data directory

  • Location of Chrome's data directory is /data/data/com.android.chrome.
  • Most of the browsing data (e.g. History, Top sites, Web Data, Cookies, Log in Data) is under /data/data/com.android.chrome/app_chrome/Default, which is the profile path.
  • Opened tabs are under /data/data/com.android.chrome/app_tabs/0/. 0 is the UID of primary user.

All we're going to do is delete the files responsible for resuming the previous browsing data when Chrome is loaded again. We'll simply use a script to delete those files and the deletion will be automated by .

Script

#!/bin/sh

data_dir='/data/data/com.android.chrome';
data_ac_dir=$data_dir/app_chrome/Default;
rm -f $data_ac_dir/History* $data_ac_dir/Web\ Data* $data_ac_dir/Cookies* $data_ac_dir/Visited\ Links $data_ac_dir/Favicons* $data_ac_dir/Top\ Sites* $data_ac_dir/Login\ Data* $data_dir/app_tabs/0/* $data_dir/app_chrome/Local\ State;

The script is very simple.

  1. First line is a shebang.
  2. Lines starting with data are creating variable and feeding directory location as the value.
  3. rm -f is to remove forcefully the files viz. History, Web Data, Cookies, Web Links, Favicons, Top Sites, Login Data, app tabs, Local State. * is a wildcard.

Note that this solution would not affect the Bookmarks or Preferences.

However, if you want even Bookmarks and Preferences to be cleared, simply add the following command in a new line at the bottom of the script:

rm -f $data_ac_dir/Preferences $data_ac_dir/Bookmarks*;

Save the file as Del_chrome_data.sh (.sh is important), push it into the root directory (/sdcard) of internal SD card and make it executable using as:

adb shell su -c 'chmod 667 /sdcard/Del_chrome_data.sh'

If you use a terminal app, do:

su
chmod 667 /sdcard/Del_chrome_data.sh

Check chmod to know about its usage.

Also, I do not change my script permissions in the manner noted above. I simply make them executable in my Linux machine and then push them into my Android device.

Instructions for Tasker

  1. Install and launch Tasker. Its accessibility service needs to be turned on for application based profile.

    Go to Settings → Accessibility → Tasker →On→OK.

  2. Under Tasks create a task named Del_chrome_data.
  3. Create an action in it through +Code → Run Shell, and fill these details:

    • Command: sh /sdcard/Del_chrome_data.sh
    • Check use Root
    • Store Errors in: %Catch
  4. Under Profiles create an application based profile through +Application → choose All, and Invert at the bottom → select Chrome.
  5. Link the task Del_chrome_data in it.

(Here is the exported profile, in case you run into trouble.)

Now, you may simply launch Chrome, do your browsing, open other apps, come back to Chrome, and nothing would seem to be affected.

Remove the Chrome from recent tasks list, launch Chrome, and voila! you would notice that the previous browsing data has been purged automatically.

You can also configure Tasker to run the task based on time, if you desire time based removal of browsing data.

Note: It took around 2-5 seconds on my devices to purge the files. Perhaps, those devices are slow.

We're good to go!

@tealhill supports Monica 2015-08-13 00:45:26

Tasker costs money. It would be more useful if you would edit your question and provide instructions which also work with a freeware alternative to Tasker. Your answer is still useful, though; +1.

@Riccardo Tonin 2015-08-06 14:38:01

I don't think it is possible because Chrome doesn't have lots of personalization.

Instead, try Maxthon Web Browser that allows you to surf the Internet without saving the chronology.

@tealhill supports Monica 2015-08-13 00:46:22

But does Maxthon Web Browser let you automatically clear browsing data on exit, or must you manually enter some "incognito mode" every time you use it?

@typecasto 2015-08-06 21:22:32

I would use firefox. It has an option to clear on exit. You do have to go to the menu (which you can access by tapping the menu icon) and hit quit every time, but seeming as there is no way I know of in chrome, It's better than nothing. Firefox does take some getting used to though, so switch with caution.

@Firelord 2015-08-06 21:27:18

It seems that OP is already aware of this method. But it is still an answer though! Anyhow, could you link the app in the answer? Also, this "quit" feature has to be activated first to show up in Menu. Please mention it as well.

@user598527 2017-03-29 07:50:28

OP asked about Chrome, not Firefox.

@typecasto 2017-04-09 04:58:59

@user598527 Question was originally written for firefox, then later edited.

@user598527 2017-04-09 06:41:36

@LarsonAshcroft: There's nothing about Firefox in revision history.

@typecasto 2017-05-01 01:01:33

@user598527 Guess i'm mistaken then. Sorry about that, don't know what i was thinking.

Related Questions

Sponsored Content

6 Answered Questions

[SOLVED] On Android, how to disable Google Chrome's incognito mode

2 Answered Questions

[SOLVED] How to synchronize Chrome web history on different Android devices?

7 Answered Questions

1 Answered Questions

[SOLVED] CCleaner app doesn't clear my Google Chrome browsing history

2 Answered Questions

Selectively remove Chrome (Android) browsing history

  • 2016-12-02 16:45:22
  • pmiranda
  • 292 View
  • 0 Score
  • 2 Answer
  • Tags:   history

1 Answered Questions

[SOLVED] How to exit fullscreen in android chrome?

Sponsored Content