sdcard permission denied android - 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.

Related

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

getExternalFilesDir(null) gives java.io.IOException: Read-only file system

I'm trying to write a text file in the root folder of my app with the below code
File file = new File(getExternalFilesDir(null), "values.txt");
file.createNewFile();
All i am getting is java.io.IOException: Read-only file system
i have uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" in the manifest file.
How can i fix this issue ?
I have tried it on an emulator and a nexus 7 and cant seem to find what is causing the issue.
I see a lot of answers talking about remounting my file system but i can expect everyone that downloads the app to do that.
getExternalFilesDir(null)
Will return, The path of the directory holding application files on external storage. Returns null if external storage is not currently mounted so it could not ensure the path exists; you will need to call this method again when it is available.
So In your case we don't know whether external storage is mounted or not, but as you want to put file on root folder of your app. just use getFilesDir(). It will store your file in internal storage where your application files are stored.

Issue on copying file from internal storage to sdcard

I tried to read a file from this path: data/data/com.example.app/shared_prefs/data.xml. I made a small textview in my app to show some logs. it showed me the stacktrace: /data/data/com.example.app/shared_prefs/data.xml (Permission denied) I gave the app superuser permissions and added these permissions in the AndroidManifest.xml --> android.permission.WRITE_EXTERNAL_STORAGE & android.permission.READ_EXTERNAL_STORAGE. But it still doesnt work
Giving superuser permissions to an app does not change anything as those permissions are not automatically used: superuser permissions means that you have the permission to execute something with root permissions but you don't have root permissions!
For using superuser permissions you have to execute an external application using Runtime.getRuntime().exec(..) and you have to execute it using the "su" binary. All operations performed by the external application will then be executed using superuser permission.
BTW: If you have busybox installed you can use "cp" (file copy) as the external application.

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.

how to grant android mediaserver file write permission?

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");

Categories

Resources