summaryrefslogtreecommitdiffstats
path: root/core/java/android/provider
diff options
context:
space:
mode:
authorJeff Hamilton <jham@android.com>2010-09-02 10:37:28 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-09-02 10:37:28 -0700
commit6d8fe9b40bf7ffba54c21f5b142dd247326cd9a6 (patch)
tree2dd28a9cef1559a80be31c59260ec5d5f295443f /core/java/android/provider
parentdcfd5d784c7d474e0932604a9f0dff591c3210e2 (diff)
parent88697b5a3344215f7190b3841b2fc63dae3d0c37 (diff)
downloadframeworks_base-6d8fe9b40bf7ffba54c21f5b142dd247326cd9a6.zip
frameworks_base-6d8fe9b40bf7ffba54c21f5b142dd247326cd9a6.tar.gz
frameworks_base-6d8fe9b40bf7ffba54c21f5b142dd247326cd9a6.tar.bz2
Merge "Move the searches helpers over to the new provider."
Diffstat (limited to 'core/java/android/provider')
-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);
}
/**