0

I do not understand what is going on here.

I get permission denied try trying to access External Storage on HTC Wildfire S although i set

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

in the manifest file.

String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state))

return false.

File storage= new File(Environment.getExternalStorageDirectory(),FILENAME);

By calling storage.createNewFile(); i get permission denied.

Stacktrace: java.io.IOException: Permission denied

NOTE: The same application is working correctly on all Android Samsung devices. I have the problem only on HTC and Sony devices

Thanks for your help

Festus Tamakloe
  • 11,231
  • 9
  • 53
  • 65

2 Answers2

1

Is your device plugged in your PC (USB) ? Did you check the status of your SDCard (how it is mounted, USB options while plugged in) ?

For this error : java.io.IOException: Permission denied The destination file may aldready exist. Did you check that ?

cdesir
  • 139
  • 5
  • String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) return false. The destination file doesn't exist – Festus Tamakloe Sep 30 '13 at 22:52
  • Did you check the syntax of your filename ? Check if **storage.toString()** gives you a valid path for your file, or paste the result in the post. – cdesir Sep 30 '13 at 23:00
  • Yes i do because the same application is working correctly on all Android Samsung devices. I have the problem only on HTC and Sony devices – Festus Tamakloe Sep 30 '13 at 23:04
  • Could you indicate the result of **Environment.getExternalStorageState();** in order to compare with several possible states that could cause the problem for this device (while plugged in or busy ..etc) ? ([documentation for different possible states](https://developer.android.com/reference/android/os/Environment.html)) – cdesir Sep 30 '13 at 23:12
  • Environment.getExternalStorageState() returned removed – Festus Tamakloe Sep 30 '13 at 23:16
  • Is your device connected to your PC via USB ? If so, you could try different options for the connection or just test your app while not connected – cdesir Sep 30 '13 at 23:23
0

I get the anwser by myself.

Quiet simple: i just use internal storage instead of External one.

Festus Tamakloe
  • 11,231
  • 9
  • 53
  • 65