How many database columns associated with a SMS in android?

package com.readsms;

import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

public class ReadSMS extends Activity 
{
    private static final String tag = "Whozzat";

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

        Uri sms = Uri.parse("content://sms/inbox");
        ContentResolver cr = this.getContentResolver();
        Cursor c = cr.query(sms, null, null, null, null);
        for (int i = 0; i < c.getColumnCount(); i++)
        {
            Log.v(tag, c.getColumnName(i).toString());
        }
        c.close();
    }
}

after running this code snippet I have got the following columns:

alt text


You should be able to rotate through the Cursor and look for yourself:

mCursor = managedQuery(sms, null, null, null, null);

StringBuffer info = new StringBuffer();
for( int i = 0; i < mCursor.getColumnCount(); i++) {
    info.append("Column: " + mCursor.getColumnName(i) + "\n");
}
Toast.makeText(getApplicationContext(), info.toString(), Toast.LENGTH_LONG).show();

Just try this:

public void showAllCNames (View v){
        Uri uri = Uri.parse("content://sms/");
        final Cursor cur = getContentResolver().query(uri, null, null, null, null);
        for (String s : cur.getColumnNames()){Log.d("COLUMN_NAME", s);}
}

I ran through the column name and got it:

COLUMN_NAME: _id

COLUMN_NAME: thread_id

COLUMN_NAME: address

COLUMN_NAME: person

COLUMN_NAME: date

COLUMN_NAME: date_sent

COLUMN_NAME: sc_timestamp

COLUMN_NAME: protocol

COLUMN_NAME: read

COLUMN_NAME: status

COLUMN_NAME: type

COLUMN_NAME: reply_path_present

COLUMN_NAME: subject

COLUMN_NAME: body

COLUMN_NAME: service_center

COLUMN_NAME: locked

COLUMN_NAME: sub_id

COLUMN_NAME: error_code

COLUMN_NAME: seen

COLUMN_NAME: lgeMsgType

COLUMN_NAME: lgeSiid

COLUMN_NAME: lgeCreated

COLUMN_NAME: lgeExpires

COLUMN_NAME: lgeReceived

COLUMN_NAME: lgeAction

COLUMN_NAME: lgeSec

COLUMN_NAME: lgeMac

COLUMN_NAME: lgeDoc

COLUMN_NAME: doInstalled

COLUMN_NAME: lgePinRemainCnt

COLUMN_NAME: index_on_icc

COLUMN_NAME: service_msg_sender_address

COLUMN_NAME: lgeCallbackNumber

COLUMN_NAME: sms_imsi_data


content://sms is not part of the official Android API, and as such it's not a good idea to use it. It may stop working, and some phones that use their own implementations for SMS (HTC Sense, maybe?) may have their own content provider that won't work with your code.

That said, if you really want to dig into it, you can look at the source code for it.

But again, heed this warning: http://android-developers.blogspot.com/2010/05/be-careful-with-content-providers.html.