Android 5(HTC) EACCES (Permission denied) - android

app can't create folder/file on android 5(HTC HTC6525LVW os version: 5.0.1) external storage in directory owned by app.
Parent folder is returned by [getExternalFilesDirs(String type)][1] method.
Sdcard is mounted.
Anyone else having this problem or suggestion how to solve it?
(Unfortunately I don't have this device to test it more)
Edit: From one user I know that prior this bug she encrypted sdcard and then formatted it.

Some potential ideas as to what caused it:
If the phone is running in USB Storage mode when connected to your computer you can still deploy/debug like normal but write operations will fail
You were missing a permission: in your manifest file you should check to see if you have <permission name=”android.permission.WRITE_EXTERNAL_STORAGE” >
Permissions in the wrong location: make sure that your permission tag (in manifest) is located outside of the application
Writing to the data folder can cause issues like this so make sure you're writing to sdcard and not data
This is everything I could think of. Hope it helps :)

Add permission to your manifest.xml file permissions
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Related

Access Download folder on Android 10

I have a working code that exports some files in the Downloads folder. I'm using requestLegacyExternalStorage to be able to access the folder on Android 10-. Everything works.
Since Google Play Store requested to remove the flag
requestLegacyExternalStorage="true"
I have tried to remove it. I don't need to migrate anything so it has been relatively simple and it works fine on Android 9- and Android 11. On Android 10 it does not work. The app crashes with
android.system.ErrnoException: open failed: EACCES (Permission denied)
In the AndroidManifest I have:
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="29"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
I have granted permission to access the external store.
The crash happens when I call:
destination.outputStream()
where destination is a file in the Downloads folder.
What should I do? Why doesn't this work on Android 10 only?
The issue on Android 10, because you set in In the AndroidManifest : android:maxSdkVersion="29".
Android 10 is API level 29.
add in AndroidMainfest
in application node
android:requestLegacyExternalStorage="true"

Marshmallow cannot load images from lazylist file

Hello i have different images i am loading these images from server using lazy list but its working fine below 6.0 version when i run the same code on 6.0 version its throws exception
java.io.FileNotFoundException: /storage/emulated/0/LazyList/-1246063373: open failed: ENOENT (No such file or directory)
permissions are
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Anyone please help me why i am getting this exception in 6.0 version
Now for Marshmallow(API Level 23) you need to use run time permission to access contacts or load images from gallery etc etc. You need to check it by run time. You can check below link which provide library and sample project.
https://github.com/tajchert/Nammu

Issue with application files folder in android

I'm trying to create zip file inside my application files folder (/data/data/myapp/files) but getting "failed to create zip file | open failed: EACCES (Permission denied)" error message every time. As I can see using android debug bridge, my files folder have "rwx------" permissions and "root" owner and group. I think this is the problem but I can't understand why my folder have this owner and group?
Make sure you :
have rooted your device
have the rights to write on the internal storage
are not trying to test it with the usb storage enabled on your phone
added the permission <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> in your manifest
I solved the problem by manually setting right owner, group and permissions on my application files folder (using chmod, chown and chgrp commands). It does not seem like an answer, because it is still unclear why this folder got wrong permissions but unfortunately I don't have enough time to understand where problem is.

sdcard permission denied android

I am trying to do method profiling for my application on Android 2.1 htc eris. It complains:
06-15 15:48:04.602: E/dalvikvm(826): Unable to open trace file '/sdcard/com.mayapp.trace': Permission denied
I have the following entry for user permission on my AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
When I do adb push, I get the following error:
adb push AndroidManifest.xml a.txt
failed to copy 'AndroidManifest.xml' to 'a.txt': Read-only file system
Am I missing something here?
This may not be the answer but you could use
File dir = Environment.getExternalStorageDirectory();
to access external sd card. My assumption is you wrote the directory yourself.
It was a combination of badly placed sd card and read/write access to the sdcard. Used adb push/pull to verify the sd card and also used adb remount to change the access. that solved the issue.

Cannot find Debug.startMethodTracing() trace file

I am having trouching using Debug.startMethodTracing() with my Samsung Galaxy S.
According to the Android docs, Debug.startMethodTracing("filename") writes to /sdcard/filename.trace, but I cannot find this file or folder in the DDMS File Explorer. The folder /sdcard is simply not there.
I've tried:
Debug.startMethodTracing("filename")
Debug.startMethodTracing("/mnt/sdcard/filename")
Debug.startMethodTracing("/mnt/sdcard/tmp/filename")
The first two attempts did not report an error but I couldn't find the files in DDMS File Explorer. The third generated a runtime exception stating I didn't have permission to write to that folder.
Any advice is much appreciated.
Thanks in advance,
Barry
You probably need to add WRITE_EXTERNAL_STORAGE to your manifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Categories

Resources