Reputation: 13
I want to create a simple book application in android which does not need internet connection and has been looking for the solutions.
I did get a approach here
But as per Android tutorial webview can only be used for getting the html from website which needs internet connection.
Does anyone have any better idea, how to do this or any other approach?
Thanks in advance.
Upvotes: 1
Views: 1035
Reputation: 29285
WebView
can load local HTML files in addition to fetching HTML from the Internet. So, you can write your book in HTML and embed them in your APK (assets, databases, files, etc). Then, you can dynamically load those HTML contents in a WebView
to show user your book.
Suppose you have created a HTML book called book.html
in your assets directory. Then the following code loads it into a WebView
:
WebView wv = (WebView) findViewById(R.id.webview);
wv.loadUrl("file:///android_asset/book.html");
In case of fetching HTML from a database, you can use this code.
WebView wv = (WebView) findViewById(R.id.webview);
String html = fetchHTMLFromDB();
wv.loadDataWithBaseURL("", html, "text/html", "UTF-8", "");
Upvotes: 2
Reputation: 2559
create HTML files and save it in Assets folder and open them in webview but better approach is to create database
Upvotes: 0
Reputation: 1973
I think to complete this task without internet not possible else you can save all the books in database
Upvotes: 0