meysam jahedi
پنج شنبه 28 اسفند 1393, 00:57 صبح
سلام
با دستورات زیر نام مخاطبین رو میگیرم ، میخوام جدای از اینکه تو تکس ویو نشون میده با یه حلقه for اسم مخاطبین رو بریزم تو آرایه String[] NAME اما نمیدونم چجوری (میشه این WHILE رو برداشت و FOR گذاشت؟)
Uri CONTENT_URI = ContactsContract.Contacts.CONTENT_URI;
String DISPLAY_NAME = ContactsContract.Contacts.DISPLAY_NAME;
StringBuffer output = new StringBuffer();
ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query(CONTENT_URI, null, null, null, null);
while (cursor.moveToNext() ) {
String name = cursor.getString(cursor.getColumnIndex(DISPLAY_NAM E));
output.append("\n"+ name);
output.append("\n");
}
outputText.setText(output);
}
}
با دستورات زیر نام مخاطبین رو میگیرم ، میخوام جدای از اینکه تو تکس ویو نشون میده با یه حلقه for اسم مخاطبین رو بریزم تو آرایه String[] NAME اما نمیدونم چجوری (میشه این WHILE رو برداشت و FOR گذاشت؟)
Uri CONTENT_URI = ContactsContract.Contacts.CONTENT_URI;
String DISPLAY_NAME = ContactsContract.Contacts.DISPLAY_NAME;
StringBuffer output = new StringBuffer();
ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query(CONTENT_URI, null, null, null, null);
while (cursor.moveToNext() ) {
String name = cursor.getString(cursor.getColumnIndex(DISPLAY_NAM E));
output.append("\n"+ name);
output.append("\n");
}
outputText.setText(output);
}
}