That's how i understood your problem.

That's what a base-url is for (the first paramater of
loadDataWithBaseURL).
You have to set this correctly so that URLs inside your HTML-document
can be correctly resolved.

I think that the base-url "file" is not good. For starters, it is not
a valid URL.
A base-url should be absolute, not relative. This means it should
start with a scheme ("file://" or "http://";) and followed by a domain
("/" or "someserver.com") and then a path ("", "/" or "/sdcard/test/",
etc.). That's what the 'toURL()' from my earlies post takes care of.

Have you tried my suggestions from my earlier post?


On Apr 16, 4:26 am, Ajeet Singh <ajeet.invinci...@gmail.com> wrote:
> Hi Streets Of Boston / wes
>
> Thanks for your reply.
> I think you misunderstood the problem which I mentioned above/or may
> be I have not mention it clearly. Sorry for that.
>
> I have my local HTML file which I am able to open that HTML file.
> But the problem is that my HTML file is unable to open other files
> like CSS files and Images, which are being specified in the HTML
> content like
> 1- For CCS we specify the path as
>     <link rel="stylesheet" type="text/css" href="/sdcard/ex.css" />
> 2- For mages we specify path as
>      <img src="/sdcard/testImage.jpg" width="150" height="113" />
>
> So the CSS does not gets applied and Images also does not open. :(
>
> Hope this time I am able to clear myself.
>
> Thanks for your all information.
> Ajeet Singh
>
> On Apr 16, 12:47 am, Streets Of Boston <flyingdutc...@gmail.com>
> wrote:
>
>
>
> > Have you tried this:
>
> > public class LocalFileBrowsing extends Activity {
> >     @Override
> >     public void onCreate(Bundle icicle) {
> >           super.onCreate(icicle);
> >           WebView webView = new WebView(this);
> >           setContentView(webView);
> >           File file = new File("/sdcard/Google.html");
> >           if (!file.exists())
> >                 return;
> >           byte[] arry = new byte[(int) file.length()];
> >           try {
> >                 FileInputStream fin = new FileInputStream(file);
> >                 fin.read(arry);
> >                 fin.close();
> >           } catch (Exception e) {
> >                 e.printStackTrace();
> >           }
> >           webView.loadDataWithBaseURL(  file.getAbsolutePath()  , new
> > String(arry), "text/
> > html", "utf-8", "Error: 404 ");
> >     }
>
> > }
>
> > ("file" replaced by file.getAbsolutePath())
> > If this does not work, try file.getParent().getAbsolutePath() instead.
>
> > And if either does not work, create a file Uri out of either file or
> > file.getParent() use that as your first parameter in
> > loadDataWithBaseURL: file.toURL().toString() or file.getParent().toURL
> > ().toString()
>
> > On Apr 15, 1:50 am, Ajeet Singh <ajeet.invinci...@gmail.com> wrote:
>
> > > Hi Mike,
>
> > > thanks for your reply.
> > > I already tried giving full path. But unfortunately this also does not
> > > work at all.
>
> > > Any help would be appreciated.
>
> > > Thanks,
> > > Ajeet Singh
>
> > > On Apr 14, 10:19 pm, Mike Kedl <mike.k...@gmail.com> wrote:
>
> > > > I'm just guessing since I haven't tried this myself, but wouldn't you
> > > > need to specify the path more completely in the cs statement?
> > > > Since you are reading the html in, the base is not really specified,
> > > > try either /sdcard/test_files/ex.cssor
> > > > file:///sdcard/test_files/ex.css.
> > > > (this is assuming you can read html from the filesystem at all)
>
> > > > On Tue, Apr 14, 2009 at 4:43 AM, Ajeet Singh 
> > > > <ajeet.invinci...@gmail.com> wrote:
>
> > > > > Hi all,
>
> > > > > Problem:cssis not loaded of a HTML file [ i am using
> > > > > loadDataWithBaseURL("file", new String(arry), "text/html", "utf-8", "
> > > > > ") from class WebView ]
>
> > > > > What I have done:
> > > > > 1- Pushed test.HTML file into /sdcard
> > > > > 2- Made test_files folder in /sdcard (it looks like /sdcard/
> > > > > test_files)
> > > > > 3- In folder /sdcard/test_files/ i pushed mycssfile (ex.css)
> > > > > 4- I read the test.html file into byte array and passing to function
> > > > > loadDataWithBaseURL() in string format.
>
> > > > > Its proper behavour that html file should be loaded withcss
> > > > > properties.
> > > > > Butcssdoesn't executes at all :( in this case.
>
> > > > > Can anybody help me regarding this?
> > > > > Why thecssfile is not executing at all? Is there any other way where
> > > > > I can load my html file with propercssapplied on.
>
> > > > > I am giving all my code below here?
>
> > > > > ---------------------------------------------------------------------------­­----------------------
> > > > > ---------------------------------------------------------------------------­­----------------------
> > > > > test.html
> > > > > ---------------------------------------------------------------------------­­----------------------
> > > > > <html>
> > > > > <head>
> > > > > <link rel="stylesheet" type="text/css" href="test_files/ex.css" />
> > > > > </head>
> > > > > <body>
>
> > > > > <h1>This header is 36 pt</h1> <h2>This header is blue</h2> <p>This
> > > > > paragraph has a left margin of 50 pixels</p>
>
> > > > > </body>
> > > > > </html>
> > > > > ---------------------------------------------------------------------------­­-----------------------
> > > > > ---------------------------------------------------------------------------­­------------------------
> > > > > ex.css
> > > > > ---------------------------------------------------------------------------­­----------------------
> > > > > body {background-color: yellow} h1 {font-size: 36pt} h2 {color: blue}
> > > > > p {margin-left: 50px}
>
> > > > > ---------------------------------------------------------------------------­­----------------------
> > > > > ---------------------------------------------------------------------------­­----------------------
> > > > > My java code
> > > > > ---------------------------------------------------------------------------­­----------------------
> > > > > package com.android.LocalFileBrowsing;
>
> > > > > import java.io.File;
> > > > > import java.io.FileInputStream;
>
> > > > > import android.app.Activity;
> > > > > import android.os.Bundle;
> > > > > import android.webkit.WebView;
>
> > > > > public class LocalFileBrowsing extends Activity {
> > > > >   �...@override
> > > > >    public void onCreate(Bundle icicle) {
> > > > >          super.onCreate(icicle);
> > > > >          WebView webView = new WebView(this);
> > > > >          setContentView(webView);
> > > > >          File file = new File("/sdcard/Google.html");
> > > > >          if (!file.exists())
> > > > >                return;
> > > > >          byte[] arry = new byte[(int) file.length()];
> > > > >          try {
> > > > >                FileInputStream fin = new FileInputStream(file);
> > > > >                fin.read(arry);
> > > > >                fin.close();
> > > > >          } catch (Exception e) {
> > > > >                e.printStackTrace();
> > > > >          }
>
> > > > >          webView.loadDataWithBaseURL("file", new String(arry), "text/
> > > > > html", "utf-8", "Error: 404 ");
> > > > >    }
> > > > > }
>
> > > > > Thanks in advance.
> > > > > Ajeet- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to