In that case you should use the content provider option mentioned earlier...Using a content provider would allow images as the content provider would be used for image loading too. Another alternative is to put the image inline, using the data:// scheme.
On Fri, Aug 22, 2008 at 4:47 AM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > > I already done that but there's another limit: data rendered via > loadData are not able to load remote resources (<img > src="http://...">). > > On 21 Ago, 22:21, "Megha Joshi" <[EMAIL PROTECTED]> wrote: > > On Wed, Aug 20, 2008 at 4:46 PM, Megha Joshi <[EMAIL PROTECTED]> wrote: > > > For security reasons, WebView does not allow "file:" access any more. > > > > > If you want the link to be loaded in your activity, you should provide > a > > > WebViewClient and implement shouldOverrideUrlLoading with { return > false; } > > > > This option does not work anymore, sorry for the confusion! > > > > So the only way to load local file contents into WebView, is as Gil > pointed > > out ...by loading the contents with loadData()/ > > > > Sample code: > > static final int MAXFILESIZE = 8096; > > String path = uri.getPath(); > > File f = new File(path); > > final long length = f.length(); > > if (!f.exists() || length > MAXFILESIZE) { > > return; > > } > > > > // typecast to int is safe as long as MAXFILESIZE < MAXINT > > byte[] array = new byte[(int)length]; > > > > try { > > InputStream is = new FileInputStream(f); > > is.read(array); > > is.close(); > > } catch (FileNotFoundException ex) { > > // Checked for file existance already, so this should not > happen > > return; > > } catch (IOException ex) { > > // read or close failed > > Log.e(LOGTAG, "Failed to access file: " + path, ex); > > return; > > } > > mWebView.loadData(new String(array), mimeType, null); > > > > There is a 8KB limit on the file size. So if your data is more that 8KB, > you > > should create a content provider > > for your files and then the use the ContentResolver.openContentURI()... > > > > > > > > > On Wed, Aug 20, 2008 at 4:34 PM, [EMAIL PROTECTED] < > > > [EMAIL PROTECTED]> wrote: > > > > >> I used WebView to display rich content emails (I'm writing a mail > > >> client). It worked well loading URI such as > > >> file://sdcard/filewhateveryouwant.xxx > > >> ... > > >> Now I upgraded to 0.9 and Android OS is displaying me a page with "The > > >> requested file was not found." > > > > >> Maybe a PERMISSION issue? > > > > >> On 19 Ago, 20:36, "Megha Joshi" <[EMAIL PROTECTED]> wrote: > > >> > Browser does not support viewing local files... > > > > >> > On Tue, Aug 19, 2008 at 12:38 AM, Peli <[EMAIL PROTECTED]> > wrote: > > > > >> > > Is it possible to open a local file in the browser? > > > > >> > > In the Android browser, I tried menu / go to: > > >> > > file:///sdcard/test.html > > > > >> > > I always receive the error message: > > >> > > "Web page not available. > > >> > > The web page at file:///sdcard/test.html could not be loaded as: > > >> > > The requested file was not found." > > > > >> > > even though the files exist in /sdcard/test.html. > > >> > > Do I have to use a different URL, or put files into a different > > >> > > folder? > > > > >> > > Peli > > > > >> > > PS: From within an application, there seems to be a way to load > local > > >> > > files: > > > > >> > > "The prefix "file:///android_asset/" will cause WebView to load > > >> > > content from the current application's assets folder." > > >> > > > http://code.google.com/android/reference/android/webkit/WebView.html > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

