android数据库操作:根据过滤条件获取部分通讯录信息

读取全部的通讯录,但是过滤掉黑名单中已经存在的记录,其中过滤条件必须输入为People._id,不然会报错:

03-22 14:37:51.951: ERROR/DatabaseUtils(108): android.database.sqlite.SQLiteException: ambiguous column name: _id: , while compiling: SELECT people._id AS _id, (CASE WHEN (name IS NOT NULL AND name != '') THEN name ELSE (CASE WHEN primary_organization is NOT NULL THEN (SELECT company FROM organizations WHERE organizations._id = primary_organization) ELSE (CASE WHEN primary_phone IS NOT NULL THEN (SELECT number FROM phones WHERE phones._id = primary_phone) ELSE (CASE WHEN primary_email IS NOT NULL THEN (SELECT data FROM contact_methods WHERE contact_methods._id = primary_email) ELSE null END) END) END) END) AS display_name FROM people LEFT OUTER JOIN phones ON people.primary_phone=phones._id LEFT OUTER JOIN presence ON (presence.person=people._id) WHERE (_id = 1)

很明显,这里要指定_id对应的具体表明

图片显示如下:

全部联系人列表:

android数据库操作:根据过滤条件获取部分通讯录信息_第1张图片

黑名单信息:

android数据库操作:根据过滤条件获取部分通讯录信息_第2张图片

联系人列表(已经将黑名单中的信息移除):

android数据库操作:根据过滤条件获取部分通讯录信息_第3张图片

你可能感兴趣的:(android)