Beispiel #1
0
  private void onExportData() {
    List<Item> items = mModel.getItems();
    File output = new File(EXTERNAL_DIR, FILENAME);
    if (!output.getParentFile().canWrite()) {
      showMsg(super.getString(R.string.pref_dialog_export_data_cannot_write) + output.getPath());
      return;
    }

    try {
      FileOutputStream fos = new FileOutputStream(output);
      boolean success = mModel.saveHelper(fos, items);
      if (success) {
        showMsg(R.string.pref_dialog_done);
      } else {
        showMsg(R.string.pref_dialog_export_data_fail);
      }
    } catch (Exception e) {
      showMsg("Exception occurred!");
      e.printStackTrace();
    }
  }