Hi Wes, I tried the way which you are saying. but could not make it working. It was giving "file not found" exception. Even mine HTML is not getting loaded. May be I am paasing the wrong URL to my "LocalFileContentProvider.java"
Can you give some hint how it can be done. or Can you give some sample code how the URL is paases and send to our LocalFileContentProvider.java Anyways I am pasting my code here. Can you see what I am doing wrong here? Any ways thanks for all help. What I have done is: 1- I pushed Google.html / ex.css/ test.jpg file to asset folder ____________________________________________________________________ LocalFileAccess.java ---------------------------------------- public class LocalFileAccess extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); WebView webView = new WebView(this); setContentView(webView); Uri uri = Uri.parse("content:// com.android.LocalFileAccess/Google.html"); try { is = getContentResolver().openInputStream(uri); byteArray = new byte[is.available()]; read = is.read(byteArray); System.out.println("Available: " + is.available()); System.out.println("Bytes read: " + read); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } webView.loadData(new String(byteArray), "text/html", "utf-8"); } } ____________________________________________________________________ LocalFileContentProvider.java ----------------------------------------------- public class LocalFileContentProvider extends ContentProvider { private static final String URI_PREFIX = "content:// com.android.LocalFileAccess"; public static String constructUri(String url) { Uri uri = Uri.parse(url); return uri.isAbsolute() ? url : URI_PREFIX + url; } @Override public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { //URI u = URI.create("file:///data/data/com.android.LocalFileAccess/ Google.html"); File file = new File(uri.getPath()); ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); return parcel; } // Rest of methods I override, but I did not pasted it here. } ____________________________________________________________________ AndroidManifest.xml ---------------------------------------------- <provider android:name="LocalFileContentProvider" android:authorities="com.android.LocalFileAccess" android:grantUriPermissions="true" /> ____________________________________________ Thanks, Ajeet Singh On Apr 17, 9:56 am, wescorp <wesc...@gmail.com> wrote: > After creating a ContentProvider using the mentioned tutorial, in your > html code, refer to the css as a URI such as > > <head> > <link rel=”stylesheet” type=”text/css” > href=”content://com.yournamespace.maps.LocalFileContentProvider/ > asset_filename.css” /> > </head> > > to insert the css content into the WebView. > > I use something similar for javascript. > > Cheers, > Wes > > On Apr 15, 1:23 pm, wescorp <wesc...@gmail.com> wrote: > > > > > There are several examples of content providers for different purposes > > around. > > > Here is one I found useful. > > >http://blog.tourizo.com/2009/02/how-to-display-local-file-in-android.... > > > Mark Murphy's book examples is also good for learning > > ContentProviders. > > > Cheers, > > Wes --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Discuss" group. To post to this group, send email to android-discuss@googlegroups.com To unsubscribe from this group, send email to android-discuss+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-discuss?hl=en -~----------~----~----~----~------~----~------~--~---