public ArrayList<YouTubeVideo> readAll(){
  final String SELECT_QUERY_ORDER_DESC="SELECT * FROM " + tableName + " ORDER BY "+ YouTubeVideoEntry.COLUMN_ENTRY_ID+ " DESC";
  SQLiteDatabase db=dbHelper.getReadableDatabase();
  ArrayList<YouTubeVideo> list=new ArrayList<>();
  Cursor c=db.rawQuery(SELECT_QUERY_ORDER_DESC,null);
  while (c.moveToNext()) {
    String videoId=c.getString(c.getColumnIndexOrThrow(YouTubeVideoEntry.COLUMN_VIDEO_ID));
    String title=c.getString(c.getColumnIndexOrThrow(YouTubeVideoEntry.COLUMN_TITLE));
    String duration=c.getString(c.getColumnIndexOrThrow(YouTubeVideoEntry.COLUMN_DURATION));
    String thumbnailUrl=c.getString(c.getColumnIndexOrThrow(YouTubeVideoEntry.COLUMN_THUMBNAIL_URL));
    String viewsNumber=c.getString(c.getColumnIndexOrThrow(YouTubeVideoEntry.COLUMN_VIEWS_NUMBER));
    list.add(new YouTubeVideo(videoId,title,thumbnailUrl,duration,viewsNumber));
  }
  c.close();
  return list;
}

public ArrayList < YouTubeVideo > readAll ( ) { final String SELECT_QUERY_ORDER_DESC = "SELECT * FROM " + tableName + " ORDER BY " + YouTubeVideoEntry . COLUMN_ENTRY_ID + " DESC" ; SQLiteDatabase db = dbHelper . getReadableDatabase ( ) ; ArrayList < YouTubeVideo > list = new ArrayList < > ( ) ; Cursor c = db . rawQuery ( SELECT_QUERY_ORDER_DESC , null ) ; while ( c . moveToNext ( ) ) { String videoId = c . getString ( c . getColumnIndexOrThrow ( YouTubeVideoEntry . COLUMN_VIDEO_ID ) ) ; String title = c . getString ( c . getColumnIndexOrThrow ( YouTubeVideoEntry . COLUMN_TITLE ) ) ; String duration = c . getString ( c . getColumnIndexOrThrow ( YouTubeVideoEntry . COLUMN_DURATION ) ) ; String thumbnailUrl = c . getString ( c . getColumnIndexOrThrow ( YouTubeVideoEntry . COLUMN_THUMBNAIL_URL ) ) ; String viewsNumber = c . getString ( c . getColumnIndexOrThrow ( YouTubeVideoEntry . COLUMN_VIEWS_NUMBER ) ) ; list . add ( new YouTubeVideo ( videoId , title , thumbnailUrl , duration , viewsNumber ) ) ; } c . close ( ) ; return list ; }
reads all recentlywatchedvideos from playlists database
