Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8315069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:02:18+00:00 2026-06-08T21:02:18+00:00

I am trying to access the url using the shouldOverrideUrlLoading method. For some reason

  • 0

I am trying to access the url using the shouldOverrideUrlLoading method. For some reason when I try to access the url that are present in the html files, I get Web page not available error.Previously I could access the url because I stored my html file in the raw folder but I needed to move it to assets folder as the code looks cleaner this way. This is my code, could anyone let me know how I can resolve this.

webview.setWebChromeClient(new WebChromeClient());
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("file:///android_asset/myfile/file.html");
webview.setVerticalScrollBarEnabled(false);
webview.setWebViewClient(new WebViewClient()
{
    public boolean shouldOverrideUrlLoading(WebView view, String url) {

        if (url.equalsIgnoreCase("some text")){
            setDialog("some fancy text");
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:02:20+00:00Added an answer on June 8, 2026 at 9:02 pm

    Try to get the Real Path of the file first and then try as your way like this:


    String YourURI="/android_asset/myfile/file.html";
    YourURI = new File(getRealPathFromURI(YourURI));
    
    //Got the Real Path Of the File
    
    private String getRealPathFromURI(Uri contentURI) {
      Cursor cursor = getContentResolver().query(contentURI, null, null, null, null); 
      cursor.moveToFirst(); 
      int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); 
      return cursor.getString(idx); 
    }
    
    webview.setWebChromeClient(new WebChromeClient());
    webview.setWebViewClient(new WebViewClient());
    webview.loadUrl(YourURI);                      //**Used the Real Path**
    webview.setVerticalScrollBarEnabled(false);
    webview.setWebViewClient(new WebViewClient()
    {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
    
            if (url.equalsIgnoreCase("some text")){
                setDialog("some fancy text");
            }
    }    
    

    If the File is in the SDCARD :-


    webview.setWebChromeClient(new WebChromeClient());
    webview.setWebViewClient(new WebViewClient());
    if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
    {
      Log.d(TAG, "No SDCARD");
    } 
    else 
    {
      webview.loadUrl("file://"+Environment.getExternalStorageDirectory()
                                       +"/android_asset/myfile/file.html");
    }
    webview.setVerticalScrollBarEnabled(false);
    webview.setWebViewClient(new WebViewClient()
    {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
    
            if (url.equalsIgnoreCase("some text")){
                setDialog("some fancy text");
            }
    }    
    

    Final Edit:- This Code Works Perfectly for Asset Folder


    public class MyActivity extends Activity {  
        @Override  
        public void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);
            setContentView(R.layout.webview);  
            WebView webview;  
            webview = (WebView) findViewById(R.id.webView1);  
            webview.loadUrl("file:///android_asset/myfile/file.html");
        }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access a url, get the html from it and use
I have this code that is trying to access an FTP using the URL.
I'm trying to get access to salesforce report data using oauth token. Some time
I'm trying to access an HTTPS based web service URL from a web/ear application
Ok I am trying to access some JSON using a PHP proxy as I
I'm trying to make user friendly URL using mode rewrite. My problem is, that
I'm trying to access the REST Disqus API using the following url: http://disqus.com/api/3.0/threads/listPosts.json ?api_key=myKey
I'm trying to access some data through JSON RPC using the trac XMLRPCPlugin using
I have a REST API that I am trying to access using Rails 3.0.1
I am trying to access a web API using a POST technique. I AM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.