For debugging purposes, I wanted to have a couple of mp3 files located somewhere "in" my android emulator. Is there anyway to directly push files from my OS file system to the storage system of android?
If so, which directory does android keep audio files?
if not, how can I access an SD card via emulator?
[update2]: The problem in update1 solved. Should use adb push.
[update1]: I followed kgiannakakis's advice to create an sdcard for my avd. However, I got Permission denied error when I try to create new directory inside it.
$ cd sdcard
$ ls
LOST.DIR
$mkdir musics
mkdir failed for musics, Permission denied
$ su mkdir musics
su: uid 10016 not allowed to su
You can find directions for emulating an SD card here.
I believe that the easiest way to copy files to the SD card is to use the adb utility.
See here for a more advanced solution.
Regarding instructions at http://android-er.blogspot.com/2009/10/create-sd-card-in-android-emulator-and.html on creating the 'pictures' folder, you can run the same commands from the adb shell, instead of running them from inside the emulator.
So get a command line at e.g. C:\Program Files (x86)\Android\android-sdk-windows\platform-tools (on 64bit windows), and run adb shell.
Then you can run the same commands:
#cd sdcard
#mkdir pictures
and create the directory successfully with no permission denied error.
Following same instructions, in DDMS I had to browse to \mnt\sdcard to find the SD card volume.
Related
If you attach android device to PC you can browse files and dirs. It is possible to get this directory using Environment.getExternalStorage(). You can use it from your application and create accessible files and dirs. It works fine.
On my devices this path looks like /storage/emulated/0 and if i try adb push to this directory i will get access denied error. Is it possible to copy files using adb to the same folder as Windows Explorer does?
D:\...\tools>adb push ACCOUNTS.DB /storage/emulated/0
failed to copy 'ACCOUNTS.DB' to '/storage/emulated/0': Permission denied
58969 KB/s (606505 bytes in 0.010s)
I'm implementing automated import/export and i want files to be accessible without adb shell in case anything will go wrong.
Currently using variable$EXTERNAL_STORAGE as workaround, it works for both adb and application.
Device: Asus Fonepad 7, Android 5.0, tried Genymotion Custom Tablet 6.0 - works.
Try to use /sdcard/. Although it is strongly discouraged to do this in code. It seems to be the only way with adb :
$ adb push somefile /storage/emulated/0/somefile
[100%] /storage/emulated/0/somefile
adb: error: failed to copy 'somefile' to '/storage/emulated/0/somefile': Read-only file system
$ adb push somefile /sdcard/somefile
[100%] /sdcard/somefile
By the way, on my device they don't have the same value : Environment.getExternalStorage() points to /storage/emulated/0/ while /sdcard points to /storage/emulated/legacy.
It's pretty easy, internal storage is unavailable on non-rooted devices. So as was mentioned in bwt answer you just need to push your data to sdcard :
adb push somefile /sdcard/somefile
With retrieving files from your filesystem you'll also have few problems. But with the case of pulling a database from a debug application - you'll just need to change file permission via chmod.
Here you have a useful link - XDA guys about adb
I was attempting to access the data data folder of an application without rooting . I followed How to access data/data folder in Android device? and was able to access the folder.
Now I was trying to copy the required file from data/data to a folder in my SD Card , however I get a permission denied on it. In the thread I have referenced above , no body complained of this behaviour so I suppose it shouldn't happen at my end too .
This is exactly what I am doing
C:\AndroidSdk\platform-tools>adb shell
shell#D6503:/ $ run-as com.xxx.xxx
run-as com.xxx.xxx
shell#D6503:/data/data/com.xxx.xxx $ cp databases/xxx.db /storage/sdcard1/Pictures/
cp: /storage/sdcard1/Pictures/xxx.db: Permission denied
I have verified that the folder /storage/sdcard1/Pictures is accessible through shell.
Happened to me as well. This is what I did to access the contents of the data folder of my app in my Nexus 5 (Android 5.0), without having root access or chmoding any file:
Open a console where your ADB is located and execute:
adb backup -noapk com.your.packagename
You will be asked to accept the backup on your device. Accept it and don't use any password. Once the backup process is completed, you will have a file with .ab extension on your ADB folder.
The backup will be compressed in a special way, you can decompress it with this tool: Android Backup Extractor
To use it, unzip it and put the backup file (*.ab) on the same folder where the extractor (abe.jar) is. Then open a console there and execute the following command:
java -jar abe.jar unpack NAME_OF_BACKUP.ab NAME_OF_BACKUP.tar
Notice that the result of this operation will be a *.tar file, which can be opened or decompressed with WinRAR or many other compression tools.
OPTIONAL for SQLite Databases: If you want to see the contents of the database, you can use this Firefox plug-in: Firefox SQLite Manager
HI I am developing an android application for android on nexus 7 device.
I am trying to copy my database.db from assets to /data/data/myPackage/databases/ folder. Nothing wrong till here. No exceptions and everything runs smoothly.
But When i try to get into /data/data/ folder through adb shell or with file explorer it says permission denied or just doesnt show anything.
Am I missing something here ?
PS: myPackage is just symbolic i have my own package name in its stead
Command line is here
shell#tilapia:/ $ cd /data/
shell#tilapia:/data $ ls
opendir failed, Permission denied
You need to have your device rooted to be able to access that folder.
If you want to look at your database you can always export it to the sdcard and look at it there.
see this link for an example on how to do that
trying to export db to SDCARD
you can always get the db out of the emulator, but never from a live device or else it would be easy to write apps that read/write other apps' databases and create malware
I am trying to develop a simple pygame with Ubuntu Linux 11.10 for my Motorola android phone. I am having trouble getting the "adb push" command to work. I get an failed to copy 'foo.txt' to '/media/MOT': No such file or directory error message. What am I doing wrong?
Here is what I tried so far:
The phone's SD card is mounted at /media/MOT/ and I am able to ls, create a folder and delete a folder in it.
user#linuxlappy:~$
user#linuxlappy:~$ cd /media/MOT/
user#linuxlappy:/media/MOT$ ls
Android burstlyImageCache burstlyVideoCache data DCIM download gstomperdemo LOST.DIR slacker temp.apk
user#linuxlappy:/media/MOT$ mkdir writetest
user#linuxlappy:/media/MOT$ rmdir writetest/
The file that I am trying to copy is foo.txt in my /home/user/ directory
user#linuxlappy:/media/MOT$ cd /home/user/
user#linuxlappy:~$ ls foo.*
foo.txt foo.txt~
I enabled USB debugging on the phone with:
Settings > Applications > Development > USB debugging.
I believe I have adb installed correctly, I am able to list the phone with adb devices.
user#linuxlappy:~$ adb devices
List of devices attached
0910E8201700B017 device
When I try to push a simple text file to the SD card I get this error message.
user#linuxlappy:~$ adb push foo.txt /media/MOT
failed to copy 'foo.txt' to '/media/MOT': No such file or directory
user#linuxlappy:~$
The phone's SD card is mounted at /media/MOT/
Based on your terminal output, it is mounted on your desktop Linux environment as /media/MOT. In which case, to copy files to it, you use cp.
Using adb push, you need to use the path where the external storage resides on the phone. A common spot is /mnt/sdcard/, though it may vary. Also, bear in mind that, depending on your phone, external storage may not be available while you have it mounted as a volume on your desktop Linux environment.
Description
I'm trying to Push file (.so library) onto Android Device (Samsung NexusS) "system\lib" folder using Eclipse. But when I press "Push a file onto the device" an error appears:
[2011-06-24 15:41:21] Failed to push
selection: Read-only file system
Researches
To solve this problem I search through internet and find some articles and documentations, but nothing helps me, here are some articles and documentations which I have tried.
Read-Only File System" when trying to ADB Push an App
Here users suggest to write adb shell sysrw, but when I an permission denied error appeared:
sysrw: permission denied
Copying Files to or from an Emulator/Device Instance
Here on Android Developers Forum I found "You can use the adb commands pull and push to copy files to and from an emulator/device instance's data file. Unlike the install command, which only copies an .apk file to a specific location, the pull and push commands let you copy arbitrary directories and files to any location in an emulator/device instance."
I also try to run adb remount command, but same permission error appeared:
remount: permission denied
Question
How I can push file onto Android Device (NexusS) using eclipse or adb ?
Typically access to system folder requires root permission, so unless you have rooted your phone i.e. you have superuser permission its not possible to access system folder or change its permission.
Check this:
Rooting samsung Nexus S,
Okay I have done rooting of my device and push files into it.
To root your Android Nexus S device check How to get root and recovery for Nexus S on Windoes 7.
After do this:
$adb shell
#mount -o remount, rw -t yaffs2 /dev/block/mtdblock3 /system
#cat (file which you want) > (destination path)
Thats All !