Hi guys,

I'm trying to access the messages and print them into the LogCat, I
used a code that implement what I need using the list adapter, so I
tried to apply the same concept to print the messages on the LogCat

Here is my code:

import android.app.ListActivity;

import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListAdapter;


public class Messages extends ListActivity {

      private ListAdapter mAdapter;

       /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         Uri uri = Uri.parse("content://sms/inbox");
         Cursor c = getContentResolver().query(uri, null,
null,null,null);

         startManagingCursor(c);
         String[] columns = new String[]{"body"}; // Comment
         //int[] names = new int[]{R.id.row_entry};

         //mAdapter = new SimpleCursorAdapter(this, R.layout.main, c,
columns, names);
         //this.setListAdapter(mAdapter);
         for(int i = 0; i <= columns.length ; i++){
         Log.d("Msg: ", columns[0].toString());
         }
     }

The output in the LogCat is like this

05-11 19:51:04.732: DEBUG/test(1862): body
05-11 19:51:04.732: DEBUG/test(1862): body
05-11 19:51:04.732: DEBUG/test(1862): body
05-11 19:51:04.732: DEBUG/test(1862): body
05-11 19:51:04.732: DEBUG/test(1862): body
05-11 19:51:04.732: DEBUG/test(1862): body
05-11 19:51:04.732: DEBUG/test(1862): body

It prints this same as the number of messages in my inbox times.
I have 7 messages in my inbox so that it prints it 7 times. This is
mean that the cursor works fine but I don't know why it prints body
string. The same code is used in the list Adapter and it worked fine.

What I need is I want the application prints 3 strings. Phone number,
date and message body.

Can anyone help me with this??

With my best regards.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to