tags:

views:

24

answers:

1

I've set set files to localhost an set the href links for the epub files ..

<a href="more-utopia.epub" target="_blank"> more-utopia </a><br>

and I've try to browse from my custom web view .. but when I click to download the link , it appears no download .. and open the file in the browser with custom web view.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    WebView web = (WebView) findViewById(R.id.webview);
    web.getSettings().setJavaScriptEnabled(true);
    web.loadUrl("http://10.0.2.2/epub");
    web.setWebViewClient(new myWebView());  
}   

class myWebView extends WebViewClient{
    @Override
       public boolean shouldOverrideUrlLoading(WebView view, String url) {
        url = "http://10.0.2.2/epub/";
        view.loadUrl(url);
        return true;
    }
}

What I want to do is to download the files and want to set path the download location to user selected location .

Any helpful tips are humbly welcome.

A: 

Your code is set up to prevent people from downloading anything. Every time they click the link, you have them load the original Web page again. Try using setDownloadListener() on your WebView instead. Or, change your shouldOverrideUrlLoading() to do what your question says you want it to do.

CommonsWare