下面列出了怎么用android.webkit.WebIconDatabase的API类实例代码及写法,或者点击链接到github查看源代码。
@SuppressWarnings("deprecation")
public void clearHistory() {
this.deleteDatabase(HistoryDatabase.DATABASE_NAME);
WebViewDatabase m = WebViewDatabase.getInstance(this);
m.clearFormData();
m.clearHttpAuthUsernamePassword();
if (API < 18) {
m.clearUsernamePassword();
WebIconDatabase.getInstance().removeAllIcons();
}
if (mSystemBrowser) {
try {
//Browser.
//Browser.clearHistory(getContentResolver());
} catch (NullPointerException ignored) {
}
}
Utils.trimCache(this);
}
public static void clearHistory(@NonNull Context context, @NonNull HistoryModel historyModel) {
historyModel.deleteHistory()
.subscribeOn(Schedulers.io())
.subscribe();
WebViewDatabase m = WebViewDatabase.getInstance(context);
m.clearFormData();
m.clearHttpAuthUsernamePassword();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
//noinspection deprecation
m.clearUsernamePassword();
//noinspection deprecation
WebIconDatabase.getInstance().removeAllIcons();
}
Utils.trimCache(context);
}
public static void clearHistory(@NonNull Context context, @NonNull HistoryModel historyModel) {
historyModel.deleteHistory()
.subscribeOn(Schedulers.io())
.subscribe();
WebViewDatabase m = WebViewDatabase.getInstance(context);
m.clearFormData();
m.clearHttpAuthUsernamePassword();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
//noinspection deprecation
m.clearUsernamePassword();
//noinspection deprecation
WebIconDatabase.getInstance().removeAllIcons();
}
Utils.trimCache(context);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
setRetainInstance(true);
/**
* some devices for example Nexus 7 4.2.2 version will receive website favicon, but some
* devices may cant, Galaxy Nexus 4.2.2 version
*/
String path = FileManager.getWebViewFaviconDirPath();
if (!TextUtils.isEmpty(path)) {
WebIconDatabase.getInstance().open(FileManager.getWebViewFaviconDirPath());
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
setRetainInstance(true);
/**
* some devices for example Nexus 7 4.2.2 version will receive website favicon, but some
* devices may cant, Galaxy Nexus 4.2.2 version
*/
String path = FileManager.getWebViewFaviconDirPath();
if (!TextUtils.isEmpty(path)) {
WebIconDatabase.getInstance().open(FileManager.getWebViewFaviconDirPath());
}
}
/**
* Request all icons from the database. This call must either be called
* in the main thread or have had Looper.prepare() invoked in the calling
* thread.
*
* @param cr The ContentResolver used to access the database.
* @param where Clause to be used to limit the query from the database.
* Must be an allowable string to be passed into a database query.
* @param listener IconListener that gets the icons once they are
* retrieved.
* @removed
*/
public static final void requestAllIcons(ContentResolver cr, String where,
WebIconDatabase.IconListener listener) {
// Do nothing: this is no longer used.
}