Merge pull request #1147 from Hiperzone/development
-fixed out of bounds crash when retrieving the main profile name with se...
This commit is contained in:
@@ -222,18 +222,20 @@ public class ContactHelper {
|
||||
* @return
|
||||
*/
|
||||
public static long getMainProfileContactId(ContentResolver resolver) {
|
||||
Cursor profileCursor = resolver.query(
|
||||
ContactsContract.Profile.CONTENT_URI,
|
||||
new String[]{
|
||||
ContactsContract.Profile._ID
|
||||
},
|
||||
null, null, null);
|
||||
if (profileCursor == null) {
|
||||
Cursor profileCursor = resolver.query(ContactsContract.Profile.CONTENT_URI,
|
||||
new String[]{ ContactsContract.Profile._ID}, null, null, null);
|
||||
|
||||
if(profileCursor != null && profileCursor.getCount() != 0 && profileCursor.moveToNext()) {
|
||||
long contactId = profileCursor.getLong(0);
|
||||
profileCursor.close();
|
||||
return contactId;
|
||||
}
|
||||
else {
|
||||
if(profileCursor != null) {
|
||||
profileCursor.close();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
profileCursor.moveToNext();
|
||||
return profileCursor.getLong(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user