android - HTML5 Android Phonegap Web 应用离线缓存 list

标签 android html cordova cache-manifest

我的应用程序不保存 dbtest.xml 并且在 wi-fi 关闭时不读取。 它是文件 CordovaApp.java

package io.cordova.hellocordova;
import android.os.Bundle;
import android.webkit.WebSettings;
import org.apache.cordova.*;
public class CordovaApp extends CordovaActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        this.appView.getSettings().setDomStorageEnabled(true);
        this.appView.getSettings().setAppCacheMaxSize(1024 * 1024 * 15);  
        String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
        this.appView.getSettings().setAppCachePath(appCachePath);
        this.appView.getSettings().setAllowFileAccess(true);
        this.appView.getSettings().setAppCacheEnabled(true);
        // Set by <content src="index.html" /> in config.xml
        loadUrl(launchUrl);
    }
}

在服务器上,我添加文件 .manifest、.htaccess 和 dbtext.xml .manifest 看起来:

CACHE MANIFEST
# Wersja 0.3
# Jawnie buforowane wpisy
dbtest.xml
# All other resources (e.g. sites) require the user to be online.
NETWORK:
*

.htaccess 看起来:

<mime-mapping>
<extension>manifest</extension>
<mime-type>text/cache-manifest</mime-type>
</mime-mapping> 

而且我的 PhoneGap 应用程序不能离线工作。我做错了什么?我必须在其他文件中添加一些文本吗?我必须做什么? 谢谢

最佳答案

虽然 PhoneGap 是一个离线解决方案,其中 HTML、CSS 和 JS 文件等保存在应用程序内的 assets/www 文件夹中,但在某些情况下,您可能希望应用程序指向 HTML5 文件所在的远程服务器及其 CSS/JS 位于。它们可以下载到您的设备上,并在设备没有 Internet 连接时作为脱机文件运行。 Click Here for techniques

关于android - HTML5 Android Phonegap Web 应用离线缓存 list ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27521895/

相关文章:

android - PhoneGap+Cordova 应用程序无法在 AVD(Android 虚拟设备)上运行

android - 如何衡量 Phonegap UI 性能?

安卓。按标签查找 View

java - 使用 ViewPager2 折叠工具栏会出现滚动问题

未找到 Android L ViewAnimationUtils?

javascript - 创建图像元素并随机放置在 html5 中的 div 中

javascript - 为什么 Firefox 会阻止我的图片?

android - block 后代时关注 ListView 中的 EditText (Android)

html - 将鼠标悬停在链接底部之前,链接不可点击

使用 phonegap 创建的 android 应用程序-滚动时背景不会保持固定