summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeff Hamilton <jham@android.com>2010-08-23 10:16:43 -0500
committerJeff Hamilton <jham@android.com>2010-09-02 12:36:04 -0500
commit88697b5a3344215f7190b3841b2fc63dae3d0c37 (patch)
treea2ba9c417b520cbed572ebadc327b721dbab5b50 /core
parent7fdb2a4702ed0852aa7d699b7983e7a24df5e702 (diff)
downloadframeworks_base-88697b5a3344215f7190b3841b2fc63dae3d0c37.zip
frameworks_base-88697b5a3344215f7190b3841b2fc63dae3d0c37.tar.gz
frameworks_base-88697b5a3344215f7190b3841b2fc63dae3d0c37.tar.bz2
Move the searches helpers over to the new provider.
Change-Id: I92030a50193a66edc4364345c9411c0f2d7c2d43
Diffstat (limited to 'core')
-rw-r--r--core/java/android/provider/Browser.java34
1 files changed, 8 insertions, 26 deletions
diff --git a/core/java/android/provider/Browser.java b/core/java/android/provider/Browser.java
index c8e5921..cb6e18f 100644
--- a/core/java/android/provider/Browser.java
+++ b/core/java/android/provider/Browser.java
@@ -27,6 +27,7 @@ import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.BrowserContract.Bookmarks;
import android.provider.BrowserContract.History;
+import android.provider.BrowserContract.Searches;
import android.util.Log;
import android.webkit.WebIconDatabase;
@@ -525,29 +526,11 @@ public class Browser {
* @param search The string to add to the searches database.
*/
public static final void addSearchUrl(ContentResolver cr, String search) {
- long now = System.currentTimeMillis();
- Cursor c = null;
- try {
- c = cr.query(
- SEARCHES_URI,
- SEARCHES_PROJECTION,
- SEARCHES_WHERE_CLAUSE,
- new String [] { search },
- null);
- ContentValues map = new ContentValues();
- map.put(SearchColumns.SEARCH, search);
- map.put(SearchColumns.DATE, now);
- /* We should only get one answer that is exactly the same. */
- if (c.moveToFirst()) {
- cr.update(SEARCHES_URI, map, "_id = " + c.getInt(0), null);
- } else {
- cr.insert(SEARCHES_URI, map);
- }
- } catch (IllegalStateException e) {
- Log.e(LOGTAG, "addSearchUrl", e);
- } finally {
- if (c != null) c.close();
- }
+ // The content provider will take care of updating existing searches instead of duplicating
+ ContentValues values = new ContentValues();
+ values.put(Searches.SEARCH, search);
+ values.put(Searches.DATE, System.currentTimeMillis());
+ cr.insert(Searches.CONTENT_URI, values);
}
/**
@@ -559,7 +542,7 @@ public class Browser {
// FIXME: Should this clear the urls to which these searches lead?
// (i.e. remove google.com/query= blah blah blah)
try {
- cr.delete(SEARCHES_URI, null, null);
+ cr.delete(Searches.CONTENT_URI, null, null);
} catch (IllegalStateException e) {
Log.e(LOGTAG, "clearSearches", e);
}
@@ -578,8 +561,7 @@ public class Browser {
*/
public static final void requestAllIcons(ContentResolver cr, String where,
WebIconDatabase.IconListener listener) {
- WebIconDatabase.getInstance()
- .bulkRequestIconForPageUrl(cr, where, listener);
+ WebIconDatabase.getInstance().bulkRequestIconForPageUrl(cr, where, listener);
}
/**