Android SMS Database Columns Variation HTC/AOSP
<p>I'm trying to read sms information such as sms and received phone number and i use this code </p>

<p>`private void populateSMS(Context context, int max_count) {
        Cursor c = context.getContentResolver().query(
                Uri.parse("content://sms"), null, null, null,
                "date desc limit " + max_count);</p>

<pre><code>    int sms_icon = android.R.drawable.sym_action_email;

    if (c.moveToFirst()) {
        do {
            String callerPhoneNumber = c.getString(3);
            try {
                Long.valueOf(callerPhoneNumber.replace("+", "").replace(
                        "-", ""));
            } catch (NumberFormatException e) {
                callerPhoneNumber = c.getString(16);
                if (callerPhoneNumber == null) {
                    callerPhoneNumber = c.getString(3);

                }
            `
</code></pre>

<p>this code works fine but if i install this on AOSP system the column number changes. If i use the above code on AOSP, the application would crash and i have to change the c.getString(16) to (12) and (3) to (2) as HTC Sense 4 uses (16) and Sense 3.x uses (15) and i end up having separate projects for each system.. </p>

<p>the question what should i do to have it read all possible columns in just one project..</p>

<p>thanks</p>
