Пример #1
0
  private void setPath(File path) {
    if (path != null && path.exists()) {
      this.path = path.getAbsolutePath();

      File[] filesAsFile = path.listFiles(filter);
      AndroidUtilities.sortFilesByDateDesc(filesAsFile);

      files = new String[filesAsFile.length];
      for (int i = 0; i < files.length; i++) {
        files[i] = filesAsFile[i].getName();
      }

      setItems(files, this);
    } else {
      log.error("Cannot access sdcard.");
      setMessage(R.string.DLG_error_sdcard + "sdcard");
    }
  }
Пример #2
0
 /** If database exists, no tasks but metadata, and a backup file exists, restore it */
 private void databaseRestoreIfEmpty(Context context) {
   try {
     if (AstridPreferences.getCurrentVersion() >= UpgradeService.V3_0_0
         && !context.getDatabasePath(database.getName()).exists()) {
       // we didn't have a database! restore latest file
       File directory = BackupConstants.defaultExportDirectory();
       if (!directory.exists()) {
         return;
       }
       File[] children = directory.listFiles();
       AndroidUtilities.sortFilesByDateDesc(children);
       if (children.length > 0) {
         TasksXmlImporter.importTasks(context, children[0].getAbsolutePath(), null);
       }
     }
   } catch (Exception e) {
     Log.w("astrid-database-restore", e); // $NON-NLS-1$
   }
 }