I'm trying to push one mp3 file to (Emulator) the location /system/media/audio/ui using command adb push But, i'm having
E:\Android\android-sdk\platform-tools>adb push song.mp3 /system/media/audio/ui
failed to copy 'song.mp3' to '/system/media/audio/ui/song.mp3': Read-only file system
this error. How can i change the Permission or how to push the files to this location. Any idea?
Unless you have a really good reason not to, you should stay in the /sdcard/ folder. Except for /sdcard/, most of the file system is read-only for a normal user.
It is possible, but not recommended, to "root" the phone. After which you would have full access to the whole system. Attempting this on a real phone, could break the phone, or invalidate your warranty.
If you wish to get root-privileges on the emulator, you can look at the accepted answer to this question: how to root/getroot access on android emulator?
That means your emulator does not support the sdcard. So create the emulator with sdcard option. see the bello image...
Related
I am running a vulnerable android application on a rooted device using the Genymotion and i am trying to read shared preferences and a file in files directory inside different android application like:
/data/data/xxxx/config.xml and
/data/data/xxx/files/xxxx.xml
i am trying to read this data programmatically using a sample java application to show the data in logcat, but when i try to read the files, i get permission issue on the logcat.
The funny thing is the application is running on a rooted device, so i suppose to have access to other applications sharedpreferences.I need something like this, but show this in the logcat:
https://lightsec.wordpress.com/2014/04/28/android-sharedpreferences-insecure-storage/.
I have also tries this answer, but it does not work:
Android: Retrieving shared preferences of other application
How can i retrieve all the available keys from sharedpreferences and show in logcat?
Both of those links describe using the WORLD_XX constants as in the app you're trying to read from.
Literally no one in the world would use those constants, as they don't want their shared preferences to be read by others. Everyone uses the MODE_PRIVATE constant, so they can't be read by others.
To achieve this, you'll need to do the following:
1) Request Root Access in your app (Having a rooted phone is NOT enough). (A library like RootTools can help you do this)
2) After you get root access, then you have to read the raw .xml file from the file system, and parse it accordingly. Then you can read all the data, and even write to it if you wanted.
Sounds a bit like you're confusing having a rooted phone and your app having root access, those are different things.
I'm developing an Android application that reads and writes data in a /sdcard/MyFolder directory. I get the sdcard path trough the method Environment.getExternalStorageDirectory().
I tested the application on a Samsung device where the path returned by the method is /mnt/sdcard on which I append /MyFolder; all works fine and I can r/w files in this folder.
Now I'm trying to do the same on a Nexus device: I have put my files to read in the /sdcard/MyFolder directory and getExternalStorageDirectory() returns /storage/emulated/0/ as path, on which I append /MyFolder. But in this case I cannot find the files to read.
I set all the storage permissions in the manifest.
Am I doing something wrong? Is there any particular issue related to an emulated directory?
Thanks
In Android 6.0, you have to handle certain permissions at runtime. Please go through this. Because READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE are considered as dangerous permissions and has to be handled at runtime.
Background
I am developing an android application that will only be used on Nexus 7 tablets (my team is also providing and has access to the hardware).
Problem
The app needs to be flexible to allow content to be added (by non-tech savvy users) to the app and accessed without an internet connection.
Our Idea
Android devices have a file system. We want to design a file system layout such that the people adding content to the application can drag and drop into the correct folder.
e.g.
AppName
Images
Videos
If the user adds a video to the videos folder of the device under our app, it will show up in the app.
We understand that this could easily go wrong (accidentally delete a folder, etc.) but this is out best attempt to solve this without having to update the app ourselves whenever new content comes up (and remember, no internet connection!).
The Question
Is it possible to access the android file system contents and insert them into an app as described in the "Our Idea" section? If so, how?
Yes. This is possible if you don't bother about content security. You can copy the content to any of the file system path in sdcard and your app can look for the folder and read the files .
Example , you can create a folder in sdcard as
sdcard/appname/media/
and create a layout to access the files in the device, and when user selects the files provide option to copy it to your sdcard/appname path.
Check this link
http://developer.android.com/training/basics/data-storage/files.html
Note : the sdcard path can be accessed if you connect to any external system ( PC).
I'd like to open a file that I written copied to my cacheDir (e.g audio file, or image) with an intent, but it seems like other apps don't have the permission to this directory. It's quite reasonable (my logic tells me that only root and the app have the access to this folder), but is there any workaround for this issue?
Well, that's quite obvious my friend, use activity.getExternalCacheDir() to obtain a cache dir on your SD card. Just don't forget to set the permissions.
I have created an xml file here: /data/data/com.appName/emergency.xml
Now I want to access this file from my desktop.
I am able to access the SD card through my java code. In this case, I think, the file is created in the internal memory of the device. So is it possible to access the file emergency.xml?
if you have a non-rooted device then you can't get that file from your desktop since it is readable only for the "com.appName" app. You can try to do "adb pull /data/data/com.appName/emergency.xml", but that should not work on a normal device.
But if "com.appName" is your app then you can let the app copy the file to a place where you can access it from your desktop (e.g. /sdcard).
Example Code for file copy: http://www.roseindia.net/java/beginners/CopyFile.shtml
Now I know that this works on rooted devices (which you really should probably have if you want to do serious dev work), and I THINK it will work for nonroot devices. Basically you enter the adb shell and then do something like "dd if=/data/data/com.appName/emergency.xml of=/sdcard/emergency.xml". Then you should be able to pull the file with adb pull off the sdcard.