diff options
author | Fred Quintana <fredq@google.com> | 2010-02-25 10:59:52 -0800 |
---|---|---|
committer | Fred Quintana <fredq@google.com> | 2010-02-25 10:59:52 -0800 |
commit | ee74858f1f68a915ab42b89a258ff1e7eff47b06 (patch) | |
tree | f2977f87d20f5a6b35516bee398e6abde0dc8db5 /core | |
parent | d2f246162e9c0e4090fd0ade2e0797b3779a2037 (diff) | |
download | frameworks_base-ee74858f1f68a915ab42b89a258ff1e7eff47b06.zip frameworks_base-ee74858f1f68a915ab42b89a258ff1e7eff47b06.tar.gz frameworks_base-ee74858f1f68a915ab42b89a258ff1e7eff47b06.tar.bz2 |
make the SyncStateContentProviderHelper.update() method return an indication if the row to update still exists
Diffstat (limited to 'core')
-rw-r--r-- | core/java/com/android/internal/content/SyncStateContentProviderHelper.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/java/com/android/internal/content/SyncStateContentProviderHelper.java b/core/java/com/android/internal/content/SyncStateContentProviderHelper.java index cd6a9a1..274082c 100644 --- a/core/java/com/android/internal/content/SyncStateContentProviderHelper.java +++ b/core/java/com/android/internal/content/SyncStateContentProviderHelper.java @@ -50,6 +50,11 @@ public class SyncStateContentProviderHelper { public static final String PATH = "syncstate"; + private static final String QUERY_COUNT_SYNC_STATE_ROWS = + "SELECT count(*)" + + " FROM " + SYNC_STATE_TABLE + + " WHERE " + SyncStateContract.Columns._ID + "=?"; + public void createDatabase(SQLiteDatabase db) { db.execSQL("DROP TABLE IF EXISTS " + SYNC_STATE_TABLE); db.execSQL("CREATE TABLE " + SYNC_STATE_TABLE + " (" @@ -96,11 +101,17 @@ public class SyncStateContentProviderHelper { return db.update(SYNC_STATE_TABLE, values, selection, selectionArgs); } - public void update(SQLiteDatabase db, long rowId, Object data) { + public int update(SQLiteDatabase db, long rowId, Object data) { + if (DatabaseUtils.longForQuery(db, QUERY_COUNT_SYNC_STATE_ROWS, + new String[]{Long.toString(rowId)}) < 1) { + return 0; + } db.execSQL("UPDATE " + SYNC_STATE_TABLE + " SET " + SyncStateContract.Columns.DATA + "=?" + " WHERE " + SyncStateContract.Columns._ID + "=" + rowId, new Object[]{data}); + // assume a row was modified since we know it exists + return 1; } public void onAccountsChanged(SQLiteDatabase db, Account[] accounts) { |