gpt4 book ai didi

java - 使用 Contacts.Groups._COUNT 获取联系人组时列_count 无效?

转载 作者:行者123 更新时间:2023-11-30 04:53:08 26 4
gpt4 key购买 nike

问题 1.

我有这门课:

public class ContactGroups {

// Form an array specifying which columns to return.
String[] projection = new String[] { Contacts.Groups._ID,
Contacts.Groups._COUNT, Contacts.Groups.NAME, Contacts.Groups.NOTES };

public Cursor getList(Activity act) {

Uri contacts = Contacts.Groups.CONTENT_URI;
// using the debugger code kills here
Cursor managedCursor = act.managedQuery(contacts, projection,
null,
null
, null
);
return managedCursor;
}

public ArrayList<String> getColumnData(Cursor cur) {
ArrayList<String> aa = new ArrayList<String>();
if (cur.moveToFirst()) {

String name;
String notes;
int nameColumn = cur.getColumnIndex(Contacts.Groups.NAME);
int notesColumn = cur.getColumnIndex(Contacts.Groups.NOTES);

do {
// Get the field values
name = cur.getString(nameColumn);
notes = cur.getString(notesColumn);
aa.add(name);
// Do something with the values.

} while (cur.moveToNext());

}
return aa;
}

}

我这样调用它:

ContactGroups mGrp= new ContactGroups();
final ArrayAdapter<String> aa;
aa = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,mGrp.getColumnData(mGrp.getList(this)));
myListView.setAdapter(aa);

并且拥有:

<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>

我收到找不到源错误和一个 Logcat 错误

ERROR/DatabaseUtils(617): java.lang.IllegalArgumentException: 列_count 无效

有人知道为什么吗?

问题 2.

我在哪里创建手动联系人组?

最佳答案

Contacts.Groups已弃用。你应该使用 ContactsContract .

您可能感兴趣的常量在 ContactsContract.Groups 下,特别是 SUMMARY_COUNT 的计数

关于java - 使用 Contacts.Groups._COUNT 获取联系人组时列_count 无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2342804/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com