I am trying to have an epub file link to an html document that is stored locally on my device.
I have an <a> tag with the href being:
"file://sdcard/mobi/content/file.html".
This does not work.
The epub file is currently located in the mobi directory as shown above, is there a way to relatively access the html file or is my href wrong?
I have tested the reader and it can open the file.html page if it is hosted on our local network.
Thank you in advance for any help
Related
I'm trying to view my HTML file on the android mobile browser.
My HTML file has the following code:
<html>
<head>
<title>Testy</title>
</head>
<body>
<h1>Captain is Here</h1>
<img src='captain.jpg' width='30%' alt='Testy'/>
</body>
</html>
The image(captain.jpg) is also in the same folder where the HTML page is located. I'm getting the image on the computer browser but when I'm trying to open it in mobile browser image, not showing. I tried giving different file paths. How can I achieve this by giving a universal path by that a mobile that containing these HTML files should open in respective browsers and render images too?
1- your image size is too large try an image with a smaller size or resize or format your image into a smaller size.
try src-'./caption.jpg' instead of src='caption.jpg'
Opening through directry location of Html in Chrome Solve this.
For that get html file location directry in details by file manager
Example storage/emulated/0/web_folder/file.html and copy it
After that
1.Open chrome
2.type file:/// and Paste directry location
3."file:///storage/emulated/0/web_folder/file.html" Now it can run with image
Ensure that storage permission allowed to chrome
For that Open permission settings for chrome and allow storage permission
that's where mhtml and URLs get used!!!
Have you ever downloaded a page using chrome in android? if so you would have known about mhtml
MHTML, an initialism of "MIME encapsulation of aggregate HTML documents", is a web page archive format used to combine, in a single computer file, the HTML code and its companion resources (such as images, Flash animations, Java applets, and audio and video files) that are represented by external hyperlinks in the web page's HTML code
to convert your html to mhtml you may use some tools but you can also do it manually .
converting need not rename the file as index.mhtml but use all necessary files as hyperlinks
you may use image hosting sites like imgur or imgbb or even firebase if your familiar.
after you host get the link by
right-clicking image
open image in new tab
copy link
use it(link) instead of captain.jpg
Here is an example of how to get link using imgbb
I want to open files into WebView. My all files saved in internal storage. I want to keep my files private. Files type can be PDF, txt and MS-Word etc.
I have tried using Content Provider but it not works for PDF and MS-Word files.
I tried the below code for open in WebView.
String doc= "<iframe src='http://docs.google.com/viewer?url="+Uri.parse(path)+"width='100%' height='100%' style='border: none;'></iframe>";
web.loadUrl(doc);
How can I open internally stored files in webview?
I have tried using Content Provider but it not works for PDF and MS-Word files.
A ContentProvider works equally well for all MIME types.
I tried the below code for open in WebView.
That is using an undocumented, unsupported URL for displaying Web-hosted content in a Google-supplied document-rendering page. That has no ability to access files on a device.
How can I open internally stored files in webview?
For certain types of files — such as plain text, HTML, and some image formats — WebView will be able to display the content directly. Just use loadUrl() with the file URL.
For a few other types of files, you may be able to find third-party JavaScript that you can use. For example, for PDF, you could modify Mozilla's PDF.js to be able to work with local PDFs.
The only general-purpose solution is for you to learn JavaScript and write your own document-rendering code. Put that JavaScript (and related HTML/images/CSS) in your Android app, and have it open the local filesystem content using file URL values.
I want to save a .rtf Rich text file with my app as offline help. when the user clicks for offline help, the app will show this text file. I don't want to use pdf help file because it wont be accessible on phone with no pdf viewer.
I would like to use html offline page stored in Assets folder if that is a better approach than the RTF file.
I have seen this Loading existing .html file with android WebView just looking for the .rtf file answer now
I would like to load a html file (with pictures and videos) on a Android tablet, however, there is no internet connection, thus I cannot use url for the pictures and stuff....
Is there any free web servers that allow me to do so (displaying the web content at local host)?
Or is there any way I can do it by writing a android app for it?
Thanks!!
Webview's LoadURL method can take local content. using the file uri retrieving the content from your assets and render it that way. Assuming you follow the standard folder structure for a basic HTML website.
And why would you want to ask about "free web servers" if you don't even have a internet connection... All the content has to be loaded locally on the app or downloaded on the fly (assuming you don't download too much.. if its too much then you are better off packaging it in the app).
Without Internet your html page is static page.
You can store the html file in your local assets folder then:
url = "file:///android_asset/" + mName + ".html";
mWebView.loadUrl(url);
and if you also want to show the images in your web page change the source path of images in source code of html page to local folder and pate all the images to that folder.
I am currently having problems referenceing a a file created into internal storage from my web view. the same code can reference similar file through href from a web address but when I decided to save the same file into internal storage I get Web Page at /data/data/packageName/files/fileName.html might be temporarily down.... any help would be appreciated
The line below resulted in an error when clicked on Webview:
<a href='/data/data/packageName/files/fileName.html'>
in fact when I tried with file:// the click was completely ignored as in <a href='/data/data/packageName/files/fileName.html'>
Meanwhile the same line works with <a href="http://www.someweb.co.uk/fileName.html'> is there any known workaround?