David Wardlaw
David Wardlaw

Reputation: 1

Unable to populate a fragment list with data from SQLite

I am a newbie to Android so apologies if this is a silly question......

I have an android app which when you select a value from a drawer slider a list of names will be displayed on a list fragment and these names should be sourced from an SQLite database.

Here is my code and it has been written in my Fragment class....

DatabaseHelper helper = new DatabaseHelper(null);
    SQLiteDatabase db = helper.getWritableDatabase();   
    Cursor todoCursor = db.query(false, "Names", new String[] { "name" }, null, null, null, null, null, null);      

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, todoCursor, new String[] {"name"}, new int[] { android.R.id.text1});
    setListAdapter(adapter);
    TodoCursorAdapter ca = new TodoCursorAdapter(null, todoCursor);
    return super.onCreateView(inflater, container, savedInstanceState);

The issue i am having is that my simple cursor object creation errors due to the constructor being undefined - I have looked on-line and seem to be doing the right thing and my code looks correct compared to examples on the web. Also in eclipse the words SimpleCursorAdapter after the new word has been striked through and suggests that I use a cursor loader instead of the SimpleCursorAdapter.

Any help greatly appreciated.

Thanks

Upvotes: 0

Views: 112

Answers (1)

Jon
Jon

Reputation: 156

By striked through you mean deprecated...

Take a look at: Android SimpleCursorAdapter vs. LoaderManager/CursorLoader

For CursorLoader, take a look at: http://developer.android.com/guide/components/loaders.html

Upvotes: 1

Related Questions