コード例 #1
0
ファイル: FavAdapter.java プロジェクト: nanpian/FlyShareTV
  private void initFavdata() {
    // TODO Auto-generated method stub
    Cursor mCursor = null;
    SQLiteDatabase mSQLiteDatabase = null;
    try {
      // 获取收藏数据库的数据操作实例
      mSQLiteDatabase = favDbInstance.getDatabase();
      mCursor =
          mSQLiteDatabase.query(
              FlyShareTVdataHelper.TBL_FAV_VIDEOS,
              new String[] {"movie_id,movie_name,movie_time,movie_play_times,movie_image"},
              null,
              null,
              null,
              null,
              null);
      mCursor.moveToFirst();
      while (!mCursor.isAfterLast()) {
        FavVideoItem vItem = new FavVideoItem();
        vItem.setVideoId(mCursor.getString(mCursor.getColumnIndex(FlyShareTVdataHelper.MOVIE_ID)));
        vItem.setVideoName(
            mCursor.getString(mCursor.getColumnIndex(FlyShareTVdataHelper.MOVIE_NAME)));
        vItem.setVideoPlayTime(
            mCursor.getString(mCursor.getColumnIndex(FlyShareTVdataHelper.MOVIE_PLAY_TIMES)));
        vItem.setVideoTime(
            mCursor.getString(mCursor.getColumnIndex(FlyShareTVdataHelper.MOVIE_TIME)));
        vItem.setVideoUrl(
            mCursor.getString(mCursor.getColumnIndex(FlyShareTVdataHelper.MOVIE_IMAGE)));
        mItems.add(vItem);
        mCursor.moveToNext();

        Log.d(TAG, "Fav movie items videoname -- >>" + vItem.getVideoName());
      }

    } finally {
      if (mCursor != null && !mCursor.isClosed()) {
        mCursor.close();
      }
      favDbInstance.closeDataBase();
    }
  }