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); } } }
private void loadLastOpenedFile() { File lastOpenedFile = SharedPreferencesManager.getLastOpenedFile(this); if (lastOpenedFile != null) { try { String fileContentString = GDFileUtils.readTextFile(lastOpenedFile); fileContent_.setText(fileContentString); saveButton_.setEnabled(true); cancelButton_.setEnabled(true); fileContent_.setEnabled(true); } catch (IOException e) { Log.e(TextEditorMainActivity.TAG, "Error while opening file: " + e.getMessage(), e); } } }