Exception java.lang.ClassCastException when query contacts
<p>I was trying to get the contacts using a query through the ContactsContract
The following code throws an exception.
java.lang.ClassCastException.</p>

<pre><code>public class ContactManager extends Activity{

    ArrayList&lt;String&gt; contactsList = new ArrayList&lt;String&gt;();
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        String[] contacts = getContactNames();
    }

        public String[] getContactNames(){
            try{
        Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
                null, null, null, null);


        while (cursor.moveToNext()) { 

              contactsList.add(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
        }
        return (String []) contactsList.toArray();

        }
        catch(Exception e){
            Log.e("WOw", e.toString());
            return null;
    }
        }
        }
</code></pre>

<p>Any idea?
I did not forget to add the permission
</p>
