• Sunday, September 14, 2014

    Android - WebView with custom and local data

    How to display custom text, html and local store images on Andoid Webview



    public void viewData()
    {
    WebView w=(WebView)findViewById(R.id.webView1);

    w.getSettings().setAllowFileAccess(true);

    myData= "<html><body><img src='file:///android-res/raw/myfile.jpg' />This is test webpage</body></html>";

    w.loadDataWithBaseUrl("",mydata,"text\html","UTF-8","");

    }


    In this, i have putted a file "myfile.jpg" in res/raw/ folder.
    And putted a webView with name "webView1"

    Note:

    Assests Folder Path:->   file:///android-assests/
    Raw Folder Path:->       file:///android-res/raw/

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)

    0 comments:

    Post a Comment