1. Check out our companion app, Forums for Android! Download from Google Play

SimpleAdapterCursor and widget

Discussion in 'Application Development' started by plusmoDroid, Mar 19, 2010.

  1. plusmoDroid

    plusmoDroid Member
    Thread Starter
    5

    Mar 1, 2010
    6
    0
    5
    I've been looking this notepad example, and I want to try print the contents of the database on a screen widget.
    What I'm trying to figure out, is how to handle the cursor to have direct access to the database data.
    Could someone help me, how to do this?

    Code (Text):
    1.  
    2. private void fillData() {
    3.         // Get all of the notes from the database and create the item list
    4.         Cursor c = mDbHelper.fetchAllNotes();
    5.         startManagingCursor(c);
    6.  
    7.         String[] from = new String[] { NotesDbAdapter.KEY_TITLE };
    8.         int[] to = new int[] { R.id.text1 };
    9.        
    10.         // Now create an array adapter and set it to display using our row
    11.         SimpleCursorAdapter notes =
    12.             new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
    13.         setListAdapter(notes);
    14.     }
     

    Advertisement

Share This Page

Loading...