我使用Phonegap在Android中使用缓存的经验。
1. I want to create one app which should work online as well as offline.
2. If internet connectivity is there it should use otherwise use the history.
现在它正在使用在线..但我也需要在离线工作我的应用程序。检查网络连接:
function onDeviceReady() {
navigator.network.isReachable("phonegap.com", reachableCallback, {});
navigator.notification.alert("Server Is Ready");
}
// Check network status
//
function reachableCallback(reachability) {
// There is no consistency on the format of reachability
var networkState = reachability.code || reachability;
var states = {};
states[NetworkStatus.NOT_REACHABLE] = 'No network connection';
states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
alert('Connection type: ' + states[networkState]);
}
任何人都可以帮助我访问我的应用程序,而没有任何nwtwork连接(离线)
答案 0 :(得分:3)
使用此:
<html manifest="cache.manifest">
代替<html>
。
在名为cache.manifest
的同一目录中创建一个新文件。
该文件的内容应如下所示
CACHE MANIFEST 的index.html blabla.png