Skip to content Skip to sidebar Skip to footer

Runtime Error ,when Activity Start(activity About Listview)

This activity is receive value from db.select andthen i put some value to show in the listview model .And i don't know ,how to repair it.If you want more information please tell T

Solution 1:

ArrayList<FriendEntry> friends;
privateFriendsDB db;

please Initialize it

Solution 2:

Please make sure that your initialized both ArrayList and DB in this way..

publicclassFriendsListActivityextendsActivity
 {
privateContext context;
privateFriendsDB db;
privateArrayList<FriendEntry> friends;
privateTextView hellotext;
privateListView hellolistview;
ArrayList<HashMap<String, String>> MyArrList = newArrayList<HashMap<String, String>>();
HashMap<String, String> map;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stubsuper.onCreate(savedInstanceState);
    setContentView(R.layout.friendlist_layout); 
    **friends=newArrayList<FriendEntry>;
    db=newFriendsDB(FriendsListActivity.this);
    db.getReadableDatabse();** // For reading sqlite databaseshowAllList();
}

Solution 3:

The activity is not able to start up because of a NullPointerException

Caused by: java.lang.NullPointerException 08-21 16:15:06.771: E/AndroidRuntime(536): at com.example.sqlite.FriendsListActivity.showAllList(FriendsListActivity.java:41)

So at line 41, the possible component causing NPE could be friends.get(i).getFname()

Please debug the line

            map.put("item_fname", friends.get(i).getFname());

Post a Comment for "Runtime Error ,when Activity Start(activity About Listview)"