Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File write permission error in Android

I am writing a file to SDCard and set <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> it works good upto 3.x but on 4.0 it gives the below error.

java.io.IOException: open failed: EACCES (Permission denied)
at java.io.File.createNewFile(File.java:940)
at com.gt.mLearning.app.VideoViewActivity.copyFile(VideoViewActivity.java:204)
at com.gt.mLearning.app.VideoViewActivity.access$3(VideoViewActivity.java:193)
at com.gt.mLearning.app.VideoViewActivity$Loader.doInBackground(VideoViewActivity.java:61)
at com.gt.mLearning.app.VideoViewActivity$Loader.doInBackground(VideoViewActivity.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at java.io.File.createNewFile(File.java:933)

Any help or suggestion?

rohit

like image 945
Rohit Mandiwal Avatar asked Sep 28 '26 03:09

Rohit Mandiwal


2 Answers

Just guessing but did you probably have your phone still connected to the computer? This error might happen if your sd card is still locked as a usb device. Hope this helped, Tobias

like image 177
Tobias Reich Avatar answered Sep 30 '26 17:09

Tobias Reich


Latter on I discovered that the issue is device specific. I installed the File Manager app from Android market and it shows no write permission. It mean the Android OS implementation of that manufacturer do not provide write permission which is causing the issue.

like image 32
Rohit Mandiwal Avatar answered Sep 30 '26 15:09

Rohit Mandiwal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!