Preventing Auto-Fill in Android WebView

Working with the Android WebView can be very frustrating. One thing that was driving me nuts was that as I tried to fill out forms in a WebView it would offer suggestions from things I had typed before. It proved pretty difficult to search for a solution to the problem.

The first thing I found was a suggestion to set auto-complete=”off” on the form and/or the element. Unfortunately, that didn’t work at all in the WebView. However, I did waste a lot of time testing that out.

I tried a lot of different searches:  “webkit form input autofill”, “webkit form input autocomplete”, “android WebView disable autocomplete” and other permutations I can’t even remember. I even found this unanswered StackOverflow question.

It turns out that it’s very simple to disable the feature, just difficult to find it! It’s as simple as:

     webview.getSettings().setSaveFormData(false);

That’s it!  Pesky problem solved.

Update:  Kamal on StackOverflow added the following two lines:

     WebView.getSettings().setSavePassword(false);
     WebView.clearFormData();

I haven’t tested those two changes but they do seem very likely to help!

Leave a Reply

Your email address will not be published. Required fields are marked *