Issue with application files folder in android - 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.

Related

Can android System App (privileged) read or copy /data/tombstones

I've my app as system-priv and build along with my AOSP code. now my app needs to copy the tombstone folder which is under /data/tombstones to /sdcard.
thanks in advance
I got it worked.
There are 2 parts
i) You've to register tombstones path using FileObserver, so whenever new tombstone created you'll get the callback.
ii) Your app should have the permission to read this path otherwise you'll get an avc denied due to SELinux. So add permission to system_app.te file of sepolicy.

Android 5(HTC) EACCES (Permission denied)

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" />

Android NDK can't open any file

I'm trying to open files from C in my Android app/library. This did work at some point but stopped working after changing several things that seem completely irrelevant, and don't run until after this error occurs.
I am using the following function in C: *ppFile = fopen(fullUncFilePathAndName, "r+b"); and then again with permissions "w+b"
After each of these calls, errno = 13 (Permission Denied).
The file path is /data/data/{appFolder}/files/{filename} (got from Context.getFilesDir().getAbsolutePath(), and the working directory according to the C functions is "/". This is on internal storage, but I added the permission WRITE_EXTERNAL_STORAGE just because I had nothing else to do.
Can anyone think why reading or writing to existing and non-existent files in internal storage from an NDK library would fail with permission errors?
This problem solved itself in the best worst way possible. I deleted my app's data folder in the file browser, and then at the next build the app created its files without a hitch.
You could also clean the project and recompile from scratch.

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