android - 使用 PhoneGap 在 Android 中删除缓存

标签 android cordova

我想删除 Android 中的缓存。我正在使用 PhoneGap 技术。实际上在 Blackberry 或 iOS 中一切正常,但在 Android 中存在问题。在我的应用程序中,有一个自动建议的站名列表。第一次选站的时候还好,下次选同一个站的时候,显示的是大字体的站名(白底(单列表和我原来的站列表不一样),我觉得是由于缓存)。

我认为这是由于 Android 使用 Chrome。您能否建议我如何删除此缓存?

<input id="getStationDesc" name="getStationDesc" type="text" class="log_txtfield" disabled="disabled"/>
<script>
    var obj = actb(document.getElementById('getStationDesc'),stationList);
    //setTimeout(function(){obj.actb_keywords = custom2;},10000);
    this.actb_timeOut = -1;
    // Number of elements autocomplete can show (-1: no limit)
    this.actb_lim = 10;
    // should the auto complete be limited to the beginning of keyword?
    this.actb_firstText = true;
    // Enable Mouse Support
    this.actb_mouse = true;
    // Delimiter for multiple autocomplete.
    // Set it to empty array for single autocomplete
    this.actb_delimiter = new Array(' ',',');
    // Show widget only after this number of characters is typed in.
    this.actb_startcheck = 1;

    this.actb_bgColor = '#dbe3ec';
    this.actb_textColor = '#00256a';
    this.actb_hColor = '#dbe3ec';
    this.actb_fFamily = 'arial';
    this.actb_fSize = '16px';   
    this.actb_hStyle = 'text-decoration:underline;font-weight="bold";text-align="left"';
    function FillValues()
    {
        document.getElementById('getStationCode').value = document.getElementById('getStationDesc').value.substring(0,3);               
    }
</script>

最佳答案

您可以在 Phonegap 中手动清除缓存。在应用程序加载之前,我每次都会删除应用程序的缓存内存。试试这段代码,

super.clearCache();
super.loadUrl("file:///android_asset/www/index.html");

如果你愿意,你也可以在应用程序结尾使用。

更新:另一种解决方案,

在你的 actb() 函数之后,调用页面创建,

$("#index").trigger("pagecreate");
/*#index is the id of the page*/

关于android - 使用 PhoneGap 在 Android 中删除缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12224076/

相关文章:

android - 如何将 bitbucket 私有(private) Git 存储库添加到 AOSP?

android - GoogleService 初始化失败,状态 : 10, 缺少名称为 google_app_id 的字符串资源中的 google app id 值

android webview : blank page, 没有关于 SSL 错误的回调

android - 在移动应用程序中保持用户 session 活跃的最佳方法

ios - 移动 Jquery slider 未正确显示

jquery - 从 Jquery Mobile 切换到 AppFramework

cordova - 如何为 phonegap 3.1.0 添加 Google 分析插件?

Android应用程序无法读取外部存储文件

ios - Cordova Xcode 8 存档签名冲突

android - 以编程方式创建 ListPreference - 但条目列表为空