1

my code is Here java file

package org.example.webviewdemo;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebViewDemo extends Activity {

    private WebView webView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       webView  = (WebView) findViewById(R.id.webview_compontent);
       webView.loadUrl("file://android_asset//faq.htm");
   }

}

xml file

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 >


<WebView  
    android:id="@+id/webview_compontent"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1.0"   
/>

but i cant get page content faq.htm is in folder assets

please helpme

Jignesh Ansodariya
  • 12,583
  • 24
  • 81
  • 113

2 Answers2

4
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/folderName/index.html");
Mac
  • 146
  • 1
  • 4
0

Have you tried using Uri.fromFile( File ), and get the file from getAssets().open(fileName)??

Julian Suarez
  • 4,499
  • 4
  • 24
  • 40