SimpleAdapterCursor and widget


Last Updated:

  1. plusmoDroid

    plusmoDroid Member This Topic's Starter

    Joined:
    Mar 1, 2010
    Messages:
    6
    Likes Received:
    0
    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...