I have a rooted HTC device, and I want to access the /data/app/ directory on my phone to fix a bug, and I am looking for a way to do this from my PC rather than creating a new emulated environment just to fix that bug. It lead to a looping lock screen, where every three seconds I would end up at the lock screen.
If you have USB debugging enabled, you can try to open "adb shell" and inside of it get root permissions using "su" command. After that you can open any file in any folder through this shell window. Moving in between folders the same as in a Linux, and it's easy to Google how to do that.
We have to set up a number of android devices for a project we are working on... What we have to do is actually edit the iptables of the device. Rather then doing each one by one I'm curious if there is a way to set up one device then clone the image so that we have an exact replica of that image?
We would then perhaps use PhonixCard to reinstall that image on all of the other devices...
Not sure it matters much but the device is running 4.0.1... all of the devices that we want to replicate the image on are exactly the same device.
from a previous SO answer:
Make a nandroid backup from recovery.
Make sure that the backup is located on the sdcard.
Mount the sdcard on a computer and copy it's contents to a folder on a pc.
Copy the entire contents of the folder you made above to the target device.
Root the device than install a custom recovery if you didn't do this already.
In recovery restore the nandroid backup.
Reboot the device. Now everything should be exactly the same as on the original.
Repeat steps 4-7 for every device.
If there're lots of small files that need to be transferred, another possibility is zip them up copy to the phone and than unzip it using
adb shell unzip path/to/file.zip
Once the command is launched you can disconnect the device the process will continue as long as there're no conflicting files or folders.
So answer cloning android OS images
When I debug on the virtual Machine use Eclipse, I can easily watch the data using DDMS perspective. but how could I get data when I debug on the real machine. Does everyone has a better idea or a solution. Any answer will be appreciated.
Within the DDMS perspective in Eclipse, there is a "Device" tab.
Under the "Devices" tab, assuming you already have you device connected via a usb, you can highlight your device.
After doing so, you can use the "File Explorer" tab to look at the data (directories/files) within your connected device.
Now if this appears blank for you, take a look at the post below:
How to use File Explorer on a rooted device?
If it is not blank then, you should be able to debug your data from the "File Explorer" tab.
Database Files (sqlite):
If you are wondering where /data/ files are stored, DDMS does not have permissions to view these files.
One approach is to use
sqlite3 /data/data/dev.client.android/databases/your_database_name.db
when in debugging mode.
You can also use adb pull to retrieve the database file.
Getting the absolute path of your database can be done with
File myDbFile = getDatabasePath(YOUR_DB_NAME);
Log.i(myDbFile.getAbsolutePath());
In DDMS perspective in Eclipse, there is a "Device" tab
if you not able to see it then go in WINDOWS option then choose SELECT VIEW in this select DEVICE
go in device tab and and u can see here all listing of attach device select your real device now you can see your all logs of real device :)
I need a piece of code that helps me to store data from my computer onto android emulator (for example I want to store the "C/Users/Desktop/myFile.txt" onto my emulator sd card) and vice-versa (store file from sd card onto my computer) programmatically (because i know how to do it manually !!!!)
Thanks for your help
Use the Adroid debug bridge (adb) to push and pull files to and from your device or emulator: http://developer.android.com/tools/help/adb.html#copyfiles
If you want to automate this, you can use a shell script.
I want to add picture in emulator's gallery. But i am not able to do this. How to do this? any clue! Though i have gone through a answer posted in stack over flow but didn't get success with that answer.
Check this Once you have a virtual SD card in your emulator, if you're not comfortable with mtools or if you don't know how to mount a loopback device on Linux (which is really easy by the way), just use adb push to upload your images. Possible example:
adb shell mkdir /sdcard/Pictures
adb push mypic.jpg /sdcard/Pictures
You can also use the DDMS tool in eclipse to push or pull a file onto the emulator. On a 2.2 emulator I was able to push some .jpg images into the /mnt/sdcard/DCIM/100ANDRO folder using DDMS. I then had to go into the running emulator itself, select "Dev Tools" from the Apps screen, the select "Media Scanner" (or "Media Provider" in newer versions of Android) to get the emulator to recognize the files so they would be displayed in the Media Gallery.
First thing to do is to get the image(s) at the storage of the emulator. For this you have several options. I'll list the most common options here. But first an important note on the need to scan for this media on the emulator. As pointed out by Felby in another answer.
Where to put the images
The standard location (for the devices I've tested so far) where images from the camera are put on the device is /mnt/sdcard/DCIM/100ANDRO.
However since we need to scan manually anyway you can put them at /mnt/sdcard/Pictures or any other valid path on the (emulated) sdcard.
The /sdcard/ path is linked to /mnt/sdcard/ so that will also work. I'm just mentioning this because I've seen this path on another answer.
How to upload images to emulator
Using adb
For hardcore users, execute the adb push from command line. If you don't know how to work with adb I can recommend reading up on this help article. Make sure you have the path set correctly for your system and adb devices returns at least one device (if more specify device in command).
adb push /path/to/image.jpg /mnt/sdcard/DCIM/100ANDRO
Using eclipse (ADT)
You can achieve the same by clicking some buttons in ADT. Go to the DDMS perspective and in the file explorer select the icon on the top. Check image below for details.
image linked from http://cdn.cybersectors.com/
Scan for media
An important step not to forget is executing this tool on the Android Emulator. If you skip this the Gallery will remain empty. Many thanks to Felby for pointing this out.
I then had to go into the running emulator itself, select "Dev Tools" from the Apps screen,
the select "Media Scanner" (or "Media Provider" in newer versions of
Android) to get the emulator to recognize the files so they would be
displayed in the Media Gallery.
If you need any of the image then simply go to google.com from the browser of your emulator and search for the images as you like and click on the image. when it is opened select full size option of the image and then press and hold the mouse for some seconds, this will give you saving options. you may search the options into the context menu as well.
Hope this will help some-one.
I can put images in my SD Card in this way:
disconect my phone from USB
using adb push command line with the folder storage/sdcard and not /sdcard, example
D:\adt-bundle-windows-x86-20131030\sdk\platform-tools>adb push "d:\star.jpg" storage/sdcard
close the emulator and run again
I check in Eclipse -> DDMS -> File Explorer tab, and I see the image inside storage/sdcard folder
scanning for media might stop the developer tools sometimes... if so push the files into storage/sdcard/DCIM folder using DDMS mode as mentioned in the picture above and just restart the emulator....
I used this one, it worked for me
adb push "C:/image.jpg" /mnt/sdcard/DCIM
then run Media provider (in developer tools)
:)
you might need to set write permissions too.
adb shell
mkdir /sdcard/Pictures
mount -o rw,remount rootfs /
chmod 777 /mnt/sdcard
exit
then try to copy the image
adb push mypic.jpg /sdcard/Pictures
Still annoying, here's some instructions:
Copy files to emulator using adb
adb push MyPictures/* /sdcard/Pictures
Reboot device, which lets Android to check system for new media files
adb reboot
Then the files should show up! Super annoying to reboot, but that's the most reliable method I could find.
Note:
This scripts is meant to refresh the media gallery, but I couldn't get it to work:
adb shell "am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///sdcard/Pictures/"