Note that there are some explanatory texts on larger screens.

plurals
  1. POList contacts which are in an array
    primarykey
    data
    text
    <p>I have an array with some phoneNumbers, and I want to select and list device contacts which are also in my array. </p> <p>Now I can only show the first phoneNumber that is also in the array.</p> <p>Here is my code:</p> <pre><code>public class Contacts extends ListActivity { SharedPreferences settings ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.contacts); setTitle("Choose a phone"); // Query: contacts with phone shorted by name settings = this.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE); String message = settings.getString("contacts", "0,0"); String [] contacts = message.split(","); String query = " IN ("; for (int i = 1; i &lt; contacts.length; i++) { query += contacts[i]; if (i &lt; contacts.length - 1) query += ","; } query += ")"; Cursor mCursor = getContentResolver().query( Data.CONTENT_URI, new String[] { Data._ID, Data.DISPLAY_NAME, Phone.NUMBER, Phone.TYPE }, Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "' AND " + Phone.NUMBER + " IS NOT NULL AND " + Phone.NUMBER + query, null, Data.DISPLAY_NAME + " ASC"); startManagingCursor(mCursor); // Setup the list ListAdapter adapter = new SimpleCursorAdapter(this, // context android.R.layout.simple_list_item_2, // Layout for the rows mCursor, // cursor new String[] { Data.DISPLAY_NAME, Phone.NUMBER }, // cursor // fields new int[] { android.R.id.text1, android.R.id.text2 } // view // fields ); setListAdapter(adapter); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload