这是java代码:
public class ReadContactActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button queBtn = (Button)findViewById(R.id.query);
queBtn.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
readContact();
}
}
);
}
public void readContact()
{
Cursor cursor = this.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while(cursor.moveToFirst())
{
int index = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String name = cursor.getString(index);
Toast.makeText(this, name, Toast.LENGTH_SHORT).show();
}
}
}
这是描述文件:
请高手看看是哪里不对?运行的时候出现出错!