dimanche 4 octobre 2015

displaying a new textview with the result of a request to a sqllite database

I would like to have a button which creates a new textview at the click of it. I have the onCreate method which executes the following function:

public void request(View v) {
    SQLiteDatabase db = mDbHelper.getReadableDatabase();

    String[] projection = {
            FeedReaderContract.FeedEntry._ID,
            FeedReaderContract.FeedEntry.COLUMN_NAME_TITLE,
    };


    String sortOrder =
            FeedReaderContract.FeedEntry.COLUMN_NAME_TITLE + " DESC";

    Cursor cursor = db.query(
            FeedReaderContract.FeedEntry.TABLE_NAME,  // The table to query
            projection,                               // The columns to return
            null,                                // The columns for the WHERE clause
            null,                            // The values for the WHERE clause
            null,                                     // don't group the rows
            null,                                    // don't filter by row groups
            sortOrder                                 // The sort order
    );


}

How do I show the content of the cursor on the new textview? Which method do I need to use and how I complete the code above?

Aucun commentaire:

Enregistrer un commentaire