I'm trying to check if a file exists in the application directory in internal storage with the code below
String path = Environment.getExternalStorageDirectory().getPath()+"/meu_diretorio/arquivo";
boolean exists = (new File(path)).exists();
if (!exists) {
Toast.makeText(getActivity(), "O arquivo não existe!", Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(getActivity(), "O arquivo existe!", Toast.LENGTH_SHORT).show();
}
I'm using the permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
However it is not working. How should I proceed with this verification?