如何:添加带有SQLite数据库书签功能 [英] How to: Adding a bookmark feature with SQLite Database

查看:181
本文介绍了如何:添加带有SQLite数据库书签功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在想办法,使这项工作,我只是不明白这一点。

I've been thinking of ways to make this work, and I just dont get it.

我有使用web视图被观看多个HTML文件,我想这个网页视图页面上创建书签按钮。

I have several HTML files that are viewed using webView, I want to create a bookmark button on this WebView page.

如果我创建一个表和三列的数据库 - 包含_id,标题和URL,并与标题和网址(从资产的文件夹)填充它,然后给每一个标识。当添加到书签按钮被点击的WebView中活动,它可以填充在收藏活动的ListView,并点击标题时,找到对应的SQLDB,然后打开它。网址

If I create a DB with a table and three columns - containing the _id, the Title, and the URL, and populate it with the Titles and the URLs(from assets folder) and give each an IDs. When the "Add to Bookmark" button is clicked in the WebView activity, can it populate a ListView in the Favorites activity, and when the title is clicked, it locates the URL that corresponds in the SQLDB and then open it.

我用Google搜索上SQLDB,但大多数教程不利用已存储数据的DB。

I have googled on SQLDB, but most of the tutorials do not make use of an already stored data in DB.

感谢您。

推荐答案

好吧利用这个code:

Alright use this code :

   // Saving the bookmark via ContentProvider
    final ContentValues bookmarkValues = new ContentValues();
    bookmarkValues.put(Browser.BookmarkColumns.TITLE, title);
    bookmarkValues.put(Browser.BookmarkColumns.URL, url);
    bookmarkValues.put(Browser.BookmarkColumns.BOOKMARK, 1);

    final Uri newBookmark = getContentResolver().insert(Browser.BOOKMARKS_URI, bookmarkValues);

    // Retrieving       
    Cursor cursor = getContentResolver().query(Browser.BOOKMARKS_URI, 
            null, null, null, Browser.BookmarkColumns.CREATED);

    cursor.moveToFirst();
    final String stitle = cursor.getString(cursor.getColumnIndex("title"));
    final String surl = cursor.getString(cursor.getColumnIndex("url"));

这篇关于如何:添加带有SQLite数据库书签功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆