I currently have a basic program that runs through all the SMS and creates a Thread for each one only storing the name, number, and last text. It then creates a listview out of all these threads (like the stock sms app)... But it runs really slow; how could I make this more efficient so it doesn't take minutes each time it boots?
Uri message = Uri.parse("content://sms/");
ContentResolver cr = this.getContentResolver();
Cursor c = cr.query(message, null, null, null, null);
this.startManagingCursor(c);
int totalSMS = c.getCount();
        if (c.moveToFirst()) {
         for (int i = 0; i < totalSMS; i++) {
                String[] projection = new String[] {ContactsContract.PhoneLookup.DISPLAY_NAME,ContactsContract.PhoneLookup._ID};
                Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(c.getString(c.getColumnIndexOrThrow("address"))));
                Cursor cursor2 = this.getContentResolver().query(contactUri, projection, null, null, null);
                String name = getContactName(this, c.getString(c.getColumnIndexOrThrow("address")));
                String number = c.getString(c.getColumnIndexOrThrow("address"));
                String msg =c.getString(c.getColumnIndexOrThrow("body"));
                if (cursor2.moveToFirst()) {
                    // Get values from contacts database:
                    //contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup._ID));
                    name =      cursor2.getString(cursor2.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
                }
                //entries.add(new Entry(name, msg));
                int newNumber = 1;
                for(int d = 0; d < threads.size(); d++)
                {
                    Thread t = threads.get(d);
                    if(t.number.equals(number))
                        newNumber = 0;
                }
                if(newNumber == 1)
                    threads.add(new Thread(name, number, msg));
                c.moveToNext();
            }
        }
 
     
     
    