1. Download our Official Android App: Forums for Android!

Apps SimpleAdapterCursor and widget

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

  1. plusmoDroid

    plusmoDroid Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Mar 1, 2010

    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...