I want to know how to read files placed in root folder. For instance let's take file /init.trace.rc. When I'm trying to read it I get exception:
java.io.FileNotFoundException: /init.trace.rc: EACCES (Permission denied)
I thought that I need to get superuser access. I did it but that made no difference ((( I still can't read it. Could anybody help me? ...and also I wonder how file explorers like "RootExplorer" read that stuff?
apparently this is all you need to run to get root access:
Process root = Runtime.getRuntime().exec("su");
taken from:
How can I get root permissions through the Android SDK?
Related
I need to execute an sh file using commandline option from the android program. I tried using Runtime.getRuntime().exec. I tried to pass the command as string as well as string[]. But still the issue exists. I have already given permission for read and write in external storage in manifest file.
I tried by using the paths such as
getContext().getFilesDir() +
"/data/user/0//files/..."
Environment.getExternalStorageDirectory() +
path in our system such as C:\Users\...
I tried using cp, rm, ls....and the commands that I needed actually..
For all the above trials, IO Exception occurred. (Either Permission denied or No such file or directory)
Could you know a possible solution to get out of this error and execute the sh file using command line in android program.
Thank you in advance
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.
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.
I am developing several AudioEffect subclasses that are being compiled into Android 4.0.3 ICS... I am trying to dump raw PCM data to files, but because the AudioEffects run in the context of the mediaserver process it seems there is no file writing permissions available.
fopen("/data/local/tmp/pcm_in.pcm", "w");
is returning a NULL pointer and errno 13 (permission denied).
Any ideas how I can grant mediaserver this permission, or write to a folder I can access? I'm compiling the OS, so anything goes...
More specifically: How are permissions for these native/system services determined? I don't suppose they have a AndroidManifest.xml...
I suspect the problem is that you don't have permissions to create a file at /data/local/tmp. In fact i'm not even sure that directory exists on Android.
Instead you should either use the private storage for an app or save the files to the SD card. See this for more information: http://developer.android.com/guide/topics/data/data-storage.html
Maybe you can just create a folder with permission.
root#android:/mount -o remount,rw /
root#android:/mkdir test
root#android:/chown media:media test
root#android:/chmod 777 test
Then you can do whatever you want.
z.B.
fopen("/test/pcm_in.pcm", "w");
How can I write a file in the /cache directory? I continue to get a FileNotFoundException (Permission denied).
Someone told me about the android.permission.ACCESS_CACHE_FILESYSTEM but i can't find it in the Android reference.
Any help will be appreciated.
EDIT: i'm using level 13 apis
You can only write to the cache directory of your own application: use context.getCacheDir() to get its location.