- SharedPreferences
Сохранить:
context.getSharedPreferences(Constants.SHARED_PREFERENCES_KEY, context.MODE_PRIVATE)
.edit()
.putString(KEY, doc.html()) // или doc.outerHtml(), или doc.toString(), или каким-либо другим способом
.commit();
Загрузить:
String htmlDoc = context.getSharedPreferences(Constants.SHARED_PREFERENCES_KEY, context.MODE_PRIVATE)
.getString(KEY, null);
Document doc = Jsoup.parse(htmlDoc);
- Файл в кэше:
Сохранить:
File f = new File(context.getCacheDir(), "filename.html");
org.apache.commons.io.FileUtils.writeStringToFile(f, doc.html(), StandardCharsets.UTF_8);
Загрузить:
File f = new File(context.getCacheDir(), "filename.html");
String htmlDoc = org.apache.commons.io.FileUtils.readFileToFile(f, StandardCharsets.UTF_8);
Document doc = Jsoup.parse(htmlDoc);
Если не нравится org.apache.commons.io.FileUtils
, можно записать/прочитать любым другим способом.