我想制作一个可以在phonegap中离线时保存或加载数据缓存的应用程序,但它不起作用这是我的代码,public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//super.onCreate(savedInstanceState);
//super.setIntegerProperty("splashscreen", R.drawable.ic_launcher);
//super.loadUrl("http://192.168.43.190/TA/index.php");
//WebView webView = new WebView( context );
super.appView.getSettings().setAppCacheMaxSize( 5 * 1024 * 1024 ); // 5MB
super.appView.getSettings().setAppCachePath( getApplicationContext().getCacheDir().getAbsolutePath() );
super.appView.getSettings().setAllowFileAccess( true );
super.appView.getSettings().setAppCacheEnabled( true );
super.appView.getSettings().setJavaScriptEnabled( true );
super.appView.getSettings().setCacheMode( WebSettings.LOAD_DEFAULT ); // load online by default
if (!isNetworkAvailable() ) { // loading offline
super.appView.getSettings().setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK );
}
super.loadUrl( "http://192.168.43.190/TA/index.php" );
}
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( CONNECTIVITY_SERVICE );
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
}
有没有人可以帮助我...?谢谢 :D