I am preparing a contact app where i need to get the list of Mimetypes supported by android contacts.
For ex: Some devices support SIP address
and some devices.
So i want to insert SIP address when it is supported then how can check that mimetype is supported.
I have found mimetypes table in contacts db of android in com.android.providers.contacts
package.
How I will be able to access that mimetypes table in contacts2.d
b database.
Please help.
Thank you for your help.
If you want to check a mimetype is supported by a device - here is what you would do
Uri entityUri =
Uri.withAppendedPath(
ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId), Entity.CONTENT_DIRECTORY);
Cursor c =
getContentResolver().query(
entityUri,
new String[] {
RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1 },
null, null, null);
try {
while (c.moveToNext()) {
String sourceId = c.getString(0);
if (!c.isNull(1)) {
String mimeType = c.getString(2);
String data = c.getString(3);
PackageManager packageManager = context.getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType(mimeType );
if (packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0) {
// do something - it is supported
} else {
return false;
}
}
}
} finally {
c.close();
}