diff --git a/src/com/android/email/provider/EmailContent.java b/src/com/android/email/provider/EmailContent.java index fb7fb5190..07bfe89fb 100644 --- a/src/com/android/email/provider/EmailContent.java +++ b/src/com/android/email/provider/EmailContent.java @@ -74,6 +74,8 @@ public abstract class EmailContent { }; public static final int ID_PROJECTION_COLUMN = 0; + private static final String ID_SELECTION = RECORD_ID + " =?"; + public static final String FIELD_COLUMN_NAME = "field"; public static final String ADD_COLUMN_NAME = "add"; @@ -1342,9 +1344,8 @@ public abstract class EmailContent { * @return true if an {@code accountId} is assigned to any existing account. */ public static boolean isValidId(Context context, long accountId) { - Cursor cursor = context.getContentResolver().query( - ContentUris.withAppendedId(CONTENT_URI, accountId), ID_PROJECTION, - null, null, null); + Cursor cursor = context.getContentResolver().query(CONTENT_URI, ID_PROJECTION, + ID_SELECTION, new String[] {"" + accountId}, null); try { if (cursor.moveToFirst()) { return true; diff --git a/tests/src/com/android/email/provider/ProviderTests.java b/tests/src/com/android/email/provider/ProviderTests.java index ab22659a7..a177ae78c 100644 --- a/tests/src/com/android/email/provider/ProviderTests.java +++ b/tests/src/com/android/email/provider/ProviderTests.java @@ -175,6 +175,8 @@ public class ProviderTests extends ProviderTestCase2 { assertTrue(Account.isValidId(mMockContext, account2.mId)); assertFalse(Account.isValidId(mMockContext, 1234567)); // Some random ID + assertFalse(Account.isValidId(mMockContext, -1)); + assertFalse(Account.isValidId(mMockContext, -500)); } private final static String[] MAILBOX_UNREAD_COUNT_PROJECTION = new String [] {