I have a problem, when the device is online, i can read the news to my website, i parsing use library jsoup, but when the device is offline, the pages that were read will be empty, My question is how when offline i can still read the news already read, whether it is stored in the cache, and if stored how do i get it? My code below is the data from my website i put in the variable DATA. Thanks.
public static String DATA;
private void setData() {
DATA = "";
final String URI = ""http://megapolitan.kompas.com/read/2013/01/02/10533531/BMW.Rasyid.Rajasa.Diselimuti.Plastik.Abuabu"";
new Thread() {
public void run() {
try {
DATA = new LoadNews().execute(URI).get();
} catch (Exception e) {
}
}
}.start();
}
private class LoadNews extends AsyncTask<String, Integer, String> {
private String itemContent;
protected void onPreExecute() {
super.onPreExecute();
}
protected String doInBackground(String... params) {
String url = params[0];
Document doc;
try {
doc = Jsoup.connect(url).get();
Elements element = doc.select("div.isi_berita2011 pt_5");
itemContent = element.toString();
return itemContent;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String result) {
dismissProgressDialog();
super.onPostExecute(result);
}
}