Convert the Emulator Output to Text file?
<p>I have created the Project on Android.I am using <strong>Ecliar</strong> platform,I got the correct output.I have retrieved contact details from my emulator.I have to copy these data in to a <strong>Text File</strong></p>

<p><strong>Code</strong></p>

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

    ListView lvItem;
    String displayName="";
    ArrayList&lt;String&gt; contactlist = new ArrayList&lt;String&gt;(); 
    ArrayAdapter&lt;String&gt; itemAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.main);

        lvItem = (ListView)this.findViewById(R.id.lvitems); 

        readContacts();

        itemAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,contactlist); 
        lvItem.setAdapter(itemAdapter);
    } 

    private void readContacts() {
        ContentResolver cr = getContentResolver();
        Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);

        while (cursor.moveToNext()) {
            displayName = ""; 

            displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
            String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
            String holder = "";
            holder = holder + displayName;

            /* Phone Number and Type */
            ArrayList&lt;String&gt; phoneList = new ArrayList&lt;String&gt;();
            if (Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) &gt; 0) {
                Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { id }, null);

                while (pCur.moveToNext()) {

                    int phoneType = pCur.getInt(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
                    String pnum = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));

                    switch (phoneType) {
                        case ContactsContract.CommonDataKinds.Phone.TYPE_HOME:
                            phoneList.add(", Home, "+pnum);
                            break;
                        case ContactsContract.CommonDataKinds.Phone.TYPE_WORK:
                        phoneList.add(", Work, "+pnum);
                            break;
                        case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE:
                        phoneList.add(", Mobile, "+pnum);
                            break;
                        case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER:
                        phoneList.add(", Other, "+pnum);
                            break;
                    } 
                }   // end of while
                pCur.close();
            } // end of if

        /* Email */
        Cursor emails = cr.query(Email.CONTENT_URI, null, Email.CONTACT_ID + " = " + id, null, null);

        ArrayList&lt;String&gt; emailList = new ArrayList&lt;String&gt;();

        while (emails.moveToNext()) {
            int emailType = emails.getInt(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
            String email = emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));

            switch (emailType) {
                case ContactsContract.CommonDataKinds.Email.TYPE_HOME:
                    emailList.add(", Home, "+email);
                    break;
                case ContactsContract.CommonDataKinds.Email.TYPE_WORK:
                    emailList.add(", Work, "+email);
                    break;
                case ContactsContract.CommonDataKinds.Email.TYPE_MOBILE:
                    emailList.add(", Mobile, "+email);
                    break;
                case ContactsContract.CommonDataKinds.Email.TYPE_OTHER:
                    emailList.add(", Other, "+email);
                    break;
            }
        }
        emails.close();


        if(phoneList.size()&gt;=emailList.size()) {
        for(int i=0;i&lt;phoneList.size();i++) {
            holder = displayName + phoneList.get(i);
            try{
            holder = holder + emailList.get(i);
            }catch(Exception ex){
            holder = holder + ", , ";
            }
            contactlist.add(holder);
        }
        }else {
        for(int i=0;i&lt;emailList.size();i++) {
                try{
                holder = displayName+ phoneList.get(i);
            }catch(Exception ex){
            holder = holder + ", , ";
            }
            holder = holder + emailList.get(i);
            contactlist.add(holder);
        }
        }
    }
    Collections.sort(contactlist);
    cursor.close();
}
</code></pre>

<p>Any Solution ?</p>
