Optimisation for reading contacts in listView?
<p>I have code to read contacts, get name and number and put them in listView. Everything works but application read all contacts in the same moment. I guess that I have to read them on scroll move, but I don't now how, please help?
Thank you in advance, Wolf.</p>

<p>Here is my code:</p>

<p>ArrayList> mapa = new ArrayList>();</p>

<pre><code>        ContentResolver cr = getContentResolver();
        Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);


        if(cur.getCount() &gt; 0){
            while(cur.moveToNext()){
                id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
                if(Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) &gt; 0){

                    final Cursor numCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "  = ?", new String[]{id}, null);

                    for(numCur.moveToFirst(); !numCur.isAfterLast(); numCur.moveToNext()){

                        brTel = numCur.getString(numCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                        ime = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

                        tmpIme = new String[] {ime};

                        for(int i = 0; i &lt; tmpIme.length; i++){

                            HashMap&lt;String, String&gt; imeMapa = new HashMap&lt;String, String&gt;();
                            imeMapa.put("imeLista", ime);
                            imeMapa.put("Mobilni", brTel);
                            mapa.add(imeMapa);

                        }

                    }
                    numCur.close();

                }

            } // While
        }

        SimpleAdapter sa = new SimpleAdapter(getApplicationContext(), mapa, R.layout.imenik, new String[] {"imeLista", "Mobilni"}, new int[] {R.id.tvImeImenik, R.id.tvSamoProba});
        lImenik.setAdapter(sa);
</code></pre>
