From 1d45e4e0cb8346eb2d43c8d1740f532c6d2688f8 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 14 Jul 2016 12:14:23 +0200 Subject: [PATCH] check for already existing files or directories --- .../filemanager/fragments/ItemsFragment.java | 6 +++++- app/src/main/res/values/strings.xml | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java index fec9d06f..342cad25 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java +++ b/app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java @@ -163,7 +163,11 @@ public class ItemsFragment extends android.support.v4.app.Fragment final EditText itemName = (EditText) newItemView.findViewById(R.id.item_name); final String name = itemName.getText().toString().trim(); if (Utils.isNameValid(name)) { - File file = new File(mPath, name); + final File file = new File(mPath, name); + if (file.exists()) { + Utils.showToast(getContext(), R.string.name_taken); + return; + } final RadioGroup radio = (RadioGroup) newItemView.findViewById(R.id.dialog_radio_group); if (radio.getCheckedRadioButtonId() == R.id.dialog_radio_directory) { if (!createDirectory(file, alertDialog)) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa451f77..e99309ca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,6 +5,7 @@ Create new item Directory File + Directory or file with that name already exists The name contains invalid characters An unknown error occurred Delete