private void saveLastOpenedFileToDisk() {
   File lastOpenedFile = SharedPreferencesManager.getLastOpenedFile(this);
   if (lastOpenedFile != null) {
     try {
       String fileContentString = fileContent_.getText().toString();
       lastOpenedFile.delete();
       GDFileUtils.createTextFile(lastOpenedFile, fileContentString);
     } catch (IOException e) {
       Log.e(TextEditorMainActivity.TAG, "Error while saving file: " + e.getMessage(), e);
     }
   }
 }
  public void onCancelFileEditingClicked(View v) {
    File lastOpenedFile = SharedPreferencesManager.getLastOpenedFile(this);
    byte[] identificationData = SharedPreferencesManager.getLastOpenedFileIdentificationData(this);
    String applicationFileOpenedFrom =
        SharedPreferencesManager.getLastOpenedFileFromApplication(this);

    if (lastOpenedFile != null) {
      try {
        GDServiceClient.setServiceClientListener(
            new GDServiceClientListener() {

              @Override
              public void onReceiveMessage(
                  String application, Object params, String[] attachments, String requestID) {
                // Do nothing
              }

              @Override
              public void onMessageSent(
                  String application, String requestID, String[] attachments) {
                // Do nothing
              }
            });
        Map<String, Object> params = new HashMap<String, Object>();
        if (identificationData != null) {
          params.put("identificationData", identificationData);
        }
        GDServiceClient.sendTo(
            applicationFileOpenedFrom,
            SAVE_EDITED_FILE_SERVICE_ID,
            SAVE_EDITED_FILE_SERVICE_VERSION,
            RELEASE_EDIT_METHOD,
            params,
            new String[] {lastOpenedFile.getAbsolutePath()},
            GDICCForegroundOptions.PreferPeerInForeground);

        SharedPreferencesManager.clear(this);
        lastOpenedFile.delete();
        saveButton_.setEnabled(false);
        cancelButton_.setEnabled(false);
        fileContent_.setEnabled(false);
        fileContent_.setText("");
      } catch (GDServiceException e) {
        Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG)
            .show();
      }
    }
  }