Merge "Add null check to investigate an NPE in restoreMessageWithId."

This commit is contained in:
Makoto Onuki 2010-11-01 15:40:26 -07:00 committed by Android (Google) Code Review
commit da0d12ca36
1 changed files with 8 additions and 2 deletions

View File

@ -667,8 +667,14 @@ public abstract class EmailContent {
public static Message restoreMessageWithId(Context context, long id) {
Uri u = ContentUris.withAppendedId(Message.CONTENT_URI, id);
Cursor c = context.getContentResolver().query(u, Message.CONTENT_PROJECTION,
null, null, null);
if (context == null) {
throw new NullPointerException("context");
}
ContentResolver resolver = context.getContentResolver();
if (resolver == null) {
throw new NullPointerException("resolver");
}
Cursor c = resolver.query(u, Message.CONTENT_PROJECTION, null, null, null);
try {
if (c.moveToFirst()) {