1

インターネット接続がない場合、アプリケーションはサーバーからの最後のデータを提供する必要があります。すべての http リクエストを保存してオフライン モードで使用するための手段として HttpResponseCache を使用することをお勧めしますか?

今のところ、インターネット接続を無効にすると、例外があります。

java.net.UnknownHostException: Unable to resolve host

ディスクにデータを書き込み、オフライン モードで使用する必要がありますか?

PS HttpResponseCache を構成し、HttpURLConnection を使用します。

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.addRequestProperty("Cache-Control", "max-stale=" + maxStale);
connection.setReadTimeout(10000);
connection.setConnectTimeout(15000);
connection.setRequestMethod("GET");
connection.setUseCaches(true);
connection.setDoInput(true);
connection.connect();
4

0 に答える 0