English 中文(简体)
如何在甲状腺中取得浏览器历史?
原标题:how to get browser history in android?

我愿执行一项申请,以获取和淡化违约浏览器历史,并将浏览器历史保存到Xml档案中。 但是,浏览器史在某些装置中并未保存成xml文档。

我已执行我的申请,要求将浏览器历史带上,以拯救Xml文档如下:

private void browserHistoryDOM() {
    try{
        File newxmlfile = new File("/sdcard/Xmlfiles/briwserHistory.xml");
        newxmlfile.createNewFile();
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = documentBuilder.newDocument();
        Element rootElement = document.createElement("root");
        document.appendChild(rootElement);

        Cursor mCur = managedQuery(Browser.BOOKMARKS_URI,Browser.HISTORY_PROJECTION, null, null, null);
        mCur.moveToFirst();

        if (mCur.moveToFirst() && mCur.getCount() > 0) {
            while (mCur.isAfterLast() == false) {
                Element em = document.createElement("bookmarkIdx");
                em.appendChild(document.createTextNode(mCur.getString(Browser.HISTORY_PROJECTION_BOOKMARK_INDEX)));
                rootElement.appendChild(em);

                long callDate = Long.parseLong(mCur.getString(Browser.HISTORY_PROJECTION_DATE_INDEX));
                SimpleDateFormat datePattern = new SimpleDateFormat ("dd-MM-yyyy/h:m:s:a");
                datePattern.setTimeZone(TimeZone.getTimeZone("GMT"));
                String date_str = datePattern.format(new Date(callDate));

                Element em1 = document.createElement("dateIdx");
                em1.appendChild(document.createTextNode(date_str));
                rootElement.appendChild(em1);

                Element em2 = document.createElement("idIdx");
                em2.appendChild(document.createTextNode(mCur.getString(Browser.HISTORY_PROJECTION_ID_INDEX)));
                rootElement.appendChild(em2);

                Element em3 = document.createElement("titleIdx");
                em3.appendChild(document.createTextNode(mCur.getString(Browser.HISTORY_PROJECTION_TITLE_INDEX)));
                rootElement.appendChild(em3);

                Element em4 = document.createElement("urlIdx");
                em4.appendChild(document.createTextNode(mCur.getString(Browser.HISTORY_PROJECTION_URL_INDEX)));
                rootElement.appendChild(em4);

                Element em5 = document.createElement("visitsIdx");
                em5.appendChild(document.createTextNode(mCur.getString(Browser.HISTORY_PROJECTION_VISITS_INDEX)));
                rootElement.appendChild(em5);

                long searchDate = Long.parseLong(mCur.getString(Browser.SEARCHES_PROJECTION_DATE_INDEX));
                SimpleDateFormat datePattern1 = new SimpleDateFormat ("dd-MM-yyyy/h:m:s:a");
                datePattern1.setTimeZone(TimeZone.getTimeZone("GMT"));
                String date_str1 = datePattern.format(new Date(searchDate));

                Element em6 = document.createElement("searchDateIdx");
                em6.appendChild(document.createTextNode(date_str1));
                rootElement.appendChild(em6);

                Element em7 = document.createElement("searchIdx");
                em7.appendChild(document.createTextNode(mCur.getString(Browser.SEARCHES_PROJECTION_SEARCH_INDEX)));
                rootElement.appendChild(em7);

                Element em8 = document.createElement("truncateIdIdx");
                em8.appendChild(document.createTextNode(mCur.getString(Browser.TRUNCATE_HISTORY_PROJECTION_ID_INDEX)));
                rootElement.appendChild(em8);

                Element em9 = document.createElement("truncateOldest");
                em9.appendChild(document.createTextNode(mCur.getString(Browser.TRUNCATE_N_OLDEST)));
                rootElement.appendChild(em9);

                mCur.moveToNext();
            }
        }

        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        DOMSource source = new DOMSource(document);
        StreamResult result = new StreamResult(newxmlfile);
        transformer.transform(source, result);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

通过采用上述方法,一能够取得浏览器历史,并能够将数据节省到纸张上的xml文档中。 但是,在某些种类的甲状腺装置中,还没有完成浏览器历史,也没有将其保存到Xml档案中。 如果我对摩托罗拉·德波塔装置的 app子进行了检测,那么它就会被罚款。 但是,如果我测试一下我身上的同一数字,就在Npm702NOVO7PALADIN上测试了,那么我无法在我的Xml档案中取得浏览器历史。

最佳回答

首先,从来不易读<代码>/sdcard。 使用Environment.getExternalStorageDirectory () ,以获取外部储存的根基。

第二,<代码>Browser。 BOOKMARKS_URI 将主要为开放源Browser仪器工作,该仪器是开放源项目的一部分。 欢迎设备制造商以其他不会记录其历史、书目或<条码>中的其他内容取代该信。 同样,允许用户下载第三方浏览器,这些浏览器可能不会储存在<条码>中。

Third, NOVO7PALADIN may not have passed the Compatibility Test Suite, particularly if it does not have the Google Play Store (formerly Android Market) pre-installed. That would mean that the device manufacturer is welcome to break anything they want, including whether the open source Browser app stores things in that ContentProvider.

你们需要与NVO7PALADIN制造商联系,以了解更多情况。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签