Contacts & Autocomplete
<p>First post. I'm new to android and programming in general. What I'm attempting to is to have an autocomplete text box pop up with auto complete names from the contact list. IE, if they type in "john" it will say "John Smith" or any john in their contacts. The code is basic, I pulled it from a few tutorials.</p>

<pre><code>private void autoCompleteBox() {

        ContentResolver cr = getContentResolver();

        Uri contacts = Uri.parse("content://contacts/people");

        Cursor managedCursor1 = cr.query(contacts, null, null, null, null);

        if (managedCursor1.moveToFirst()) {

            String contactname;
            String cphoneNumber;

            int nameColumn = managedCursor1.getColumnIndex("name");
            int phoneColumn = managedCursor1.getColumnIndex("number");

            Log.d("int Name", Integer.toString(nameColumn));
            Log.d("int Number", Integer.toString(phoneColumn));

            do {
                // Get the field values
                contactname = managedCursor1.getString(nameColumn);
                cphoneNumber = managedCursor1.getString(phoneColumn);
                if ((contactname != " " || contactname != null)
                        &amp;&amp; (cphoneNumber != " " || cphoneNumber != null)) {

                    c_Name.add(contactname);
                    c_Number.add(cphoneNumber);

                    Toast.makeText(this, contactname, Toast.LENGTH_SHORT)
                    .show();
                }

            } while (managedCursor1.moveToNext());

        }

        name_Val = (String[]) c_Name.toArray(new String[c_Name.size()]);
        phone_Val = (String[]) c_Number.toArray(new String[c_Name.size()]);

        ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                android.R.layout.simple_dropdown_item_1line, name_Val);

        personName.setAdapter(adapter);

    }
</code></pre>

<p>personName is my autocompletetextbox. So it actually works when I use it in the emulator (4.2) with manually entered contacts through the people app, but when I use it on my device, it will not pop up with any names. I'm sure it's something ridiculous but I've tried to find the answer and I'm getting nowhere. Can't learn if I don't ask. </p>

<p>Here is the log</p>

<p>12-11 18:35:09.229: I/ActivityManager(578): Displayed 
12-11 18:35:11.031: I/ActivityManager(578): START u0 {cmp=com.fthatnoise.borrow.me/.AddItem} from pid 4153</p>

<p>12-11 18:35:11.161: D/dalvikvm(4153): GC_CONCURRENT freed &lt;1K, 2% free 9648K/9784K, paused 5ms+2ms, total 22ms
12-11 18:35:11.181: D/dalvikvm(4153): GC_FOR_ALLOC freed &lt;1K, 2% free 9648K/9784K, paused 21ms, total 21ms
12-11 18:35:11.181: I/dalvikvm-heap(4153): Grow heap (frag case) to 10.359MB for 960016-byte allocation
12-11 18:35:11.201: D/dalvikvm(4153): GC_FOR_ALLOC freed 0K, 2% free 10585K/10724K, paused 18ms, total 18ms
12-11 18:35:11.221: D/dalvikvm(4153): GC_CONCURRENT freed &lt;1K, 1% free 10637K/10744K, paused 3ms+1ms, total 15ms</p>

<p>12-11 18:35:11.551: I/ActivityManager(578): Displayed com.fthatnoise.borrow.me/.AddItem: +514ms
12-11 18:35:11.571: D/overlay(162): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED
12-11 18:35:11.911: D/overlay(162): FROM_STATE = OV_CLOSED TO_STATE = OV_BYPASS_3_LAYER
12-11 18:35:13.073: D/overlay(162): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED</p>
