如何在android棉花糖中清除浏览历史记录
我正在用android清理浏览器历史记录。直至android 5.1.1,即:;棒棒糖下面的语法很好用如何在android棉花糖中清除浏览历史记录,android,browser,android-6.0-marshmallow,Android,Browser,Android 6.0 Marshmallow,我正在用android清理浏览器历史记录。直至android 5.1.1,即:;棒棒糖下面的语法很好用 Browser.clearHistory(mContextUtility.getContentResolver()); 但是,对于android 6,即:;棉花糖它不起作用。那么我该如何解决这个问题呢?有没有其他方法可以清除浏览器历史记录呢?看看Android源代码,它看起来对你来说不太有希望。请注意,clearHistory方法不再执行任何操作,因此canClearHistory总是重新运
Browser.clearHistory(mContextUtility.getContentResolver());
但是,对于android 6,即:;棉花糖它不起作用。那么我该如何解决这个问题呢?有没有其他方法可以清除浏览器历史记录呢?看看Android源代码,它看起来对你来说不太有希望。请注意,clearHistory方法不再执行任何操作,因此canClearHistory总是重新运行false
/**
* Returns whether there is any history to clear.
*
* @param cr The ContentResolver used to access the database.
* @return boolean True if the history can be cleared.
* @removed
*/
public static final boolean canClearHistory(ContentResolver cr) {
return false;
}
/**
* Delete all entries from the bookmarks/history table which are
* not bookmarks. Also set all visited bookmarks to unvisited.
*
* @param cr The ContentResolver used to access the database.
* @removed
*/
public static final void clearHistory(ContentResolver cr) {
}
以下是5.1.1 r1中的相同方法,当它们实际起作用时:
public static final boolean More ...canClearHistory(ContentResolver cr) {
Cursor cursor = null;
boolean ret = false;
try {
cursor = cr.query(History.CONTENT_URI,
new String [] { History._ID, History.VISITS },
null, null, null);
ret = cursor.getCount() > 0;
} catch (IllegalStateException e) {
Log.e(LOGTAG, "canClearHistory", e);
} finally {
if (cursor != null) cursor.close();
}
return ret;
}
删除书签/历史记录表中所有未显示的条目
书签。还将所有已访问的书签设置为“未访问”。要求
android.Manifest.permission参数:用于
访问数据库
已删除对棉花糖上方书签的读写权限(API>=23)。
指
看起来您可以实现自己的浏览器应用程序,并在数据库中本地保存书签,但API>=23,您无法从Chrome访问历史记录或书签 你有什么错误吗???如果是,则发布日志。我没有收到任何错误。但是,它没有清除历史记录。已删除读取和写入棉花糖上方书签的权限(API>=23)请参阅此链接
public static final void More ...clearHistory(ContentResolver cr) {
deleteHistoryWhere(cr, null);
}