简体   繁体   中英

Compiling app with web data included for offline use

I wonder if it's possible to compile an android app with web data already included in apk for offline use. Application downloads data (HTML), saves on device(HTML and images separately) and displays it in webview, but I wonder if it's possible to compile this app with all data and pictures already in device.

WebView mWebView=(WebView)findViewById(R.id.mWebView);

            mWebView.loadUrl("file:///book.html");
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.getSettings().setSaveFormData(true);
            mWebView.getSettings().setBuiltInZoomControls(true);
            mWebView.setWebViewClient(new MyWebViewClient());

private class MyWebViewClient extends WebViewClient 
{ 
    @Override 
    //show the web page in webview but not in web browser
    public boolean shouldOverrideUrlLoading(WebView view, String url) { 
        view.loadUrl (url); 
        return true;
    }
}

For More information

http://androidtrainningcenter.blogspot.in/2012/11/android-webview-loading-custom-html-and.html

Since I store all the data in database all I have to do is go through all the categories I want be available offline at app install, store the db file in /assets/ folder and then once user launches the app for the first time use copy method from here How to put .db file from assets to data/data/packagename/ android and I'm all set. Hope this helps someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM