Exemple #1
0
  public synchronized List<String[]> queryWithArgs(String sql, String[] vArgs) throws Throwable {
    Cursor cursor = null;
    SQLiteDatabase database = null;
    List<String[]> ret = new ArrayList<String[]>();
    try {
      database = mSqliteHelper.getWritableDatabase();
      cursor = database.rawQuery(sql, vArgs);
      String[] names = cursor.getColumnNames();
      ret.add(names);
      while (cursor.moveToNext()) {
        String[] record = new String[names.length];
        for (int x = 0; x < names.length; x++) {
          record[x] = cursor.getString(x);
        }
        ret.add(record);
      }

    } finally {
      try {
        if (null != cursor) {
          cursor.close();
        }
      } finally {
        database.close();
      }
    }
    return ret;
  }
Exemple #2
0
 public void saveToSqlite(WatchHistory watchHistory) throws Throwable {
   SQLiteDatabase database = null;
   try {
     database = mSqliteHelper.getWritableDatabase();
     database.execSQL(
         "insert or replace into fsc_history("
             + "media_id, name_cn, display_type, max_index, "
             + "virtual_user, user_id, "
             + "serial_id, serial_index, serial_title, serial_clarity, serial_language, "
             + "play_time_in_seconds, operation_time)values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
         new Object[] {
           watchHistory.mediaInfo.media_id,
           watchHistory.mediaInfo.name_cn,
           watchHistory.mediaInfo.display_type,
           watchHistory.mediaInfo.max_index,
           watchHistory.userInfo.virtual_user_id,
           watchHistory.userInfo.user_id,
           watchHistory.serialInfo.serial_id,
           watchHistory.serialInfo.serial_index,
           watchHistory.serialInfo.serial_title,
           watchHistory.serialInfo.serial_clarity,
           watchHistory.serialInfo.serial_language,
           watchHistory.play_time_in_seconds,
           System.currentTimeMillis() / 1000
         });
   } finally {
     if (null != database) {
       database.close();
     }
   }
 }
Exemple #3
0
 public synchronized boolean execSql(String sql, Object[] args) throws Throwable {
   SQLiteDatabase database = null;
   try {
     database = mSqliteHelper.getWritableDatabase();
     if (args == null) {
       args = new Object[0];
     }
     database.execSQL(sql, args);
   } finally {
     if (null != database) {
       database.close();
     }
   }
   return true;
 }
Exemple #4
0
 private PlayHistoryDao(Context context) {
   this.mSqliteHelper = FunSQLiteHelper.getInstance(context);
 }