android - how to show inbox messages in list view -


i want show inbox messages in list view. have tried many way's seem there error ..

can tell different approach .

public class inbox extends listactivity  {                   arraylist<string> listitems = new arraylist<string>();         arrayadapter<string> adapter;          protected void oncreate(bundle savedinstancestate)         {                      uri urisms = uri.parse("content://sms/inbox");                cursor c = getcontentresolver().query(urisms, null, null ,null,null);                if(c.movetofirst())                {                              for(int i=0; < c.getcount(); i++)                              {   string body = c.getstring(c.getcolumnindexorthrow("body")).tostring();                                    listitems.add(body);                                  c.movetonext();                              }                              if(listitems.isempty())                                  listitems.add("no messages found !!");                 }                 c.close();                 adapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_1,listitems);                 super.oncreate(savedinstancestate);                 setlistadapter(adapter);          }  } 

why 1 not working . ??

arraylist<string> listitems = new arraylist<string>();     arrayadapter<string> adapter;      protected void oncreate(bundle savedinstancestate)     {                  super.oncreate(savedinstancestate);            uri urisms = uri.parse("content://sms/inbox");            cursor c = getcontentresolver().query(urisms, null, null ,null,null);            if(c.movetofirst())            {                          for(int i=0; < c.getcount(); i++)                          {   string body = c.getstring(c.getcolumnindexorthrow("body")).tostring();                                listitems.add(body);                              c.movetonext();                          }                          if(listitems.isempty())                              listitems.add("no messages found !!");             }             c.close();             adapter = new arrayadapter<string>(this,android.r.layout.simple_list_item_1,listitems);              setlistadapter(adapter);      }  

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

How to call a javascript function after the page loads with a chrome extension? -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -