Sms Inbox - ListView
<p>Hello i am trying to create aplication witch shows me sms in ListView but i dont know how i can fill listview by datas.I tried do that but it doesn't work.Can you check my source code and give me some resolution? Thanks</p>

<p>Source code:</p>

<pre><code>import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;


public class Mynewtwo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ListView list = (ListView) findViewById(R.id.list);
        List&lt;String&gt; msgList = getSMS();


        ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,R.layout.main, msgList); 
        list.setAdapter(adapter);
    }

    public List&lt;String&gt; getSMS(){
         List&lt;String&gt; sms = new ArrayList&lt;String&gt;();
            Uri uriSMSURI = Uri.parse("content://sms/inbox");
            Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null);

            while (cur.moveToNext()) {
                   String address = cur.getString(cur.getColumnIndex("address"));
                   String body = cur.getString(cur.getColumnIndexOrThrow("body"));
                  sms.add("Number: " + address + " .Message: " + body);  

              }
            return sms;

        }
</code></pre>

<p>}</p>

<p>XML : </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
android:id="@+id/widget30"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
&gt;
&lt;ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
&gt;
&lt;/ListView&gt;
&lt;/LinearLayout&gt;
</code></pre>
