mardi 30 juin 2015

Populate ListView in android from SQLite database

I am just learning android programming and now i am making an app that uses database. For now i am using SQLite to store the data.

I have successfully created app which can stored/insert data in a database. Its working and i have checked my database using root Explorer.

Now on 2nd activity lets say DisplayRecords, i want to display my records into list view which will populate dynamically. How can i achieve that through programming.

here is my code of 2nd activity.

public class SearchResult extends ActionBarActivity {

ListView ls;
SQLiteDatabase db;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_result);

     Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
     setSupportActionBar(toolbar);


     ls = (ListView)findViewById(R.id.displayListView);

}

Can anyone please help me

Thanks

Aucun commentaire:

Enregistrer un commentaire