'히스토리'에 해당되는 글 1

  1. 2014.11.28 브라우저 방문기록, 북마크 읽어오기 3

펌 OK (출처 표시), 상업적 이용 NO, 컨텐츠 변경 NO


1.구버전 안드로이드 기본브라우저 (약 S5 이전단말의 기본브라우저)


try {

String[] proj = new String[] { Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL};

String sel = Browser.BookmarkColumns.BOOKMARK + " = 1"; // 0 = history, 1 = bookmark

Cursor mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj, sel, null, null);

mCur.moveToFirst();

String title = "";

String url = "";


if (mCur.moveToFirst() && mCur.getCount() > 0) {

boolean cont = true;

while (mCur.isAfterLast() == false && cont) {

title = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.TITLE));

url = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.URL));

mCur.moveToNext();

      }


}

}

catch (Exception e) {

}



2. 크롬 브라우저


try {

String[] proj = new String[] { Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL, Browser.BookmarkColumns.DATE };

Uri uriCustom = Uri.parse("content://com.android.browser/bookmarks");

String sel = Browser.BookmarkColumns.BOOKMARK + " = 1"; // 0 = history, 1 = bookmark

Cursor mCur = getContentResolver().query(uriCustom, proj, sel, null, null);

mCur.moveToFirst();

String title = "";

String url = "";


if (mCur.moveToFirst() && mCur.getCount() > 0) {

boolean cont = true;

while (mCur.isAfterLast() == false && cont) {

title = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.TITLE));

url = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.URL));


        }

mCur.moveToNext();

      }


}

}

catch (Exception e) {

}


3. 최신단말의 안드로이드 S브라우저 (약 S5이후 단말에서 많이 사용하는것같음)


try {

String[] proj = new String[] { Browser.BookmarkColumns.TITLE, Browser.BookmarkColumns.URL, Browser.BookmarkColumns.DATE };

Uri uriCustom = Uri.parse("content://com.sec.android.app.sbrowser.browser/bookmarks");

String sel = Browser.BookmarkColumns.BOOKMARK + " = 1"; // 0 = history, 1 = bookmark

Cursor mCur = getContentResolver().query(uriCustom, proj, sel, null, null);

mCur.moveToFirst();

String title = "";

String url = "";


if (mCur.moveToFirst() && mCur.getCount() > 0) {

boolean cont = true;

while (mCur.isAfterLast() == false && cont) {

if (!TextUtils.isEmpty(url)) {

title = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.TITLE));

url = mCur.getString(mCur.getColumnIndex(Browser.BookmarkColumns.URL));


}

mCur.moveToNext();

      }


}

}

catch (Exception e) {

}