예제 #1
0
 /**
  * 1.insert one row information
  *
  * @param beans
  */
 public void addDownloadTask(ArrayList<DownloadBean> beans) {
   try {
     SQLiteDatabase database = dbHelper.getWritableDatabase();
     for (DownloadBean bean : beans) {
       String sql =
           "insert into download_info(url, file_name, total_size, start_pos, end_pos, compelete_size,"
               + " thread_id, file_version, file_version_code, package_name, icon_url, soft_id, download_id, version_code) values "
               + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
       Object[] bindArgs = {
         bean.url,
         bean.fileName,
         bean.fileSize,
         bean.startPosition,
         bean.endPosition,
         bean.currentPosition,
         bean.threadId,
         bean.fileVersion,
         bean.fileVersionCode,
         bean.packageName,
         bean.iconUrl,
         bean.fileId,
         bean.downloadId,
         bean.versionCode
       };
       database.execSQL(sql, bindArgs);
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
예제 #2
0
 /**
  * 1.insert records
  *
  * @param info
  */
 public void addCompleteTask(DownloadBean info) {
   try {
     SQLiteDatabase database = dbHelper.getWritableDatabase();
     String sql =
         "insert into end_download_info(url, file_name,"
             + " file_size, done_time, icon_url, file_version,"
             + " file_version_code, package_name,"
             + " file_path, soft_id, download_id, version_code) values (?,?,?,?,?,?,?,?,?,?,?,?)";
     Object[] bindArgs = {
       info.url,
       info.fileName,
       info.fileSize,
       info.doneTime,
       info.iconUrl,
       info.fileVersion,
       info.fileVersionCode,
       info.packageName,
       info.savePath,
       info.fileId,
       info.downloadId,
       info.versionCode
     };
     database.execSQL(sql, bindArgs);
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
예제 #3
0
 /**
  * 1.insert one record
  *
  * @param url
  * @param packageName
  * @param softId
  */
 public void addPauseFile(String url, String packageName, String softId, String downloadId) {
   try {
     SQLiteDatabase database = dbHelper.getWritableDatabase();
     String sql =
         "insert into pause_download_info(url, package_name, soft_id, download_id) "
             + "values (?,?,?,?)";
     Object[] bindArgs = {url, packageName, softId, downloadId};
     database.execSQL(sql, bindArgs);
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
예제 #4
0
  /**
   * @Title: clearDownloadDataBaseTables @Description: clear download database
   *
   * @return: void
   */
  public void cleanDownloadDataBaseTables() {
    try {
      SQLiteDatabase database = dbHelper.getWritableDatabase();
      String downloadInfoSql = "delete from download_info";
      String downloadPauseInfoSql = "delete from pause_download_info";
      String downloadEndSql = "delete from end_download_info";

      database.execSQL(downloadEndSql);
      database.execSQL(downloadInfoSql);
      database.execSQL(downloadPauseInfoSql);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #5
0
 public DownloadDBImpl(Context context) {
   DownloadDBHelper helper = new DownloadDBHelper(context);
   mDb = helper.getWritableDatabase();
 }