List of usage examples for android.provider DocumentsContract renameDocument
public static Uri renameDocument(ContentProviderClient client, Uri documentUri, String displayName) throws RemoteException
From source file:com.anthonymandra.support.v4.provider.DocumentsContractApi21.java
public static Uri renameTo(Context context, Uri self, String displayName) { return DocumentsContract.renameDocument(context.getContentResolver(), self, displayName); }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
@Override public void onEdittextDialogEnded(String result, String hint, EditTextDialog.Actions action) { if (Device.hasKitKatApi() && TextUtils.isEmpty(greatUri.getFilePath())) { Uri newUri = DocumentsContract.renameDocument(getContentResolver(), greatUri.getUri(), result); // if everything is ok if (newUri != null) { // delete current refreshList(greatUri, false, true); greatUri.setUri(newUri);//from ww w .j a v a2 s. co m greatUri.setFilePath(AccessStorageApi.getPath(this, newUri)); greatUri.setFileName(AccessStorageApi.getName(this, newUri)); new SaveFileTask(this, greatUri, pageSystem.getAllText(mEditor.getText().toString()), currentEncoding, new SaveFileTask.SaveFileInterface() { @Override public void fileSaved(Boolean success) { savedAFile(greatUri, true); } }).execute(); } else { Toast.makeText(this, R.string.file_cannot_be_renamed, Toast.LENGTH_SHORT).show(); } } else { File newFile = new File(greatUri.getParentFolder(), result); // if everything is ok if (new File(greatUri.getFilePath()).renameTo(newFile)) { // delete current refreshList(greatUri, false, true); greatUri.setUri(Uri.fromFile(newFile)); greatUri.setFilePath(newFile.getAbsolutePath()); greatUri.setFileName(newFile.getName()); new SaveFileTask(this, greatUri, pageSystem.getAllText(mEditor.getText().toString()), currentEncoding, new SaveFileTask.SaveFileInterface() { @Override public void fileSaved(Boolean success) { savedAFile(greatUri, true); } }).execute(); } else { Toast.makeText(this, R.string.file_cannot_be_renamed, Toast.LENGTH_SHORT).show(); } } /*new SaveFileTask(this, greatUri, pageSystem.getAllText(mEditor.getText().toString()), currentEncoding, new SaveFileTask.SaveFileInterface() { @Override public void fileSaved(Boolean success) { savedAFile(greatUri, true); } }).execute();*/ }