2

can you please tell how to remove caching in webview in android. I open one url there one textfield in that I write come text on that field and go next page .then come to same page write same thing it will open autosuggest (like thing which text I already used previously).

Thanks

here is my code

package com.firstgroup.ui;

import android.os.Bundle;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class ApplicationLoad extends Activity {
    WebView mWebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.app);

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.setWebViewClient(new MyBrowser());

        mWebView.getSettings().setLoadsImagesAutomatically(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
         mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
            mWebView.getSettings().setAppCacheEnabled(false);
        mWebView.loadUrl("http://192.168.11.90/loginuser/login");
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
         if(event.getAction() == KeyEvent.ACTION_DOWN){
                switch(keyCode)
                {
                case KeyEvent.KEYCODE_BACK:
                    if(mWebView.canGoBack() == true){
                        mWebView.goBack();
                    }else{
                        finish();
                    }
                    return true;
                }

            }
            return super.onKeyDown(keyCode, event);
    }
    private class MyBrowser extends WebViewClient {
           @Override
           public boolean shouldOverrideUrlLoading(WebView view, String url) {
              view.loadUrl(url);
              return true;
           }
        }

}



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    tools:context=".ApplicationLoad" >
<WebView 
   android:id="@+id/webview"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
/>



</RelativeLayout>

4 Answers4

2

Try by putting this in OnCreate():

//context is Activity context
context.deleteDatabase("webview.db");
context.deleteDatabase("webviewCache.db");

Also try this:

CookieSyncManager.createInstance(this);         
CookieManager cookieManager = CookieManager.getInstance();        
cookieManager.removeAllCookie();
fida1989
  • 3,234
  • 1
  • 27
  • 30
1

Try following methods of Webview,

mWebView.clearFormData();
mWebView.clearCache(true);

And to remove the EditText's border you need to declare following property in your .xml file.

android:background="@null"
Lucifer
  • 29,392
  • 25
  • 90
  • 143
0

try this for not displaying autosuggetion

mWebView.clearFormData();
mWebView.getSettings().setSavePassword(false);
mWebView.getSettings().setSaveFormData(false);
Vamshi
  • 1,495
  • 1
  • 15
  • 31
  • Secondly There is brown layout display on text field can we remove that. –  Feb 27 '14 at 08:47
  • i think that is default, if you test in different device the border color may change...you really wants to remove it? – Vamshi Feb 27 '14 at 08:53
0

// turn caching off webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

and use LOAD_CACHE_NORMAL for default behavior.

pooja
  • 107
  • 1
  • 2
  • 7