I'm playing around with syncing files from my laptop to my SD card on the phone using adb-sync.
adb-sync reports successfully pushing the files to the destination.
Navigating to /storage/9016-4EF8/Music in adb shell, the new files are listed, right after the following message:
ls: ./.android_secure: Permission denied
Yet the new files don't appear in my file explorer on the laptop. Additionally, they are not seen by my music player.
adb shell (different project - see comment) otherwise lists the contents of the SD card perfectly, AFAICT. It's only the adb-sync transfers that incorrectly show up as not being present.
Perhaps this is related, but adb shell reports success when creating new files, and these files also do not appear in my file explorer (Dolphin). Creating a new file in Dolphin works fine and is correctly listed in adb shell!
So I believe they weren't actually transferred. Or they were transferred somewhere strange in internal memory. Where might they actually be?
I've had a little time to clarify my thinking about this. Actually adb-sync is not necessary to this discussion. The problem is actually that filesystem operations within the adb shell are not reflected in the view from my file manager, Dolphin. So I launched the phone's file explorer and, voila, there's the changes!
So apparently this is a problem related to the much-decried MTP protocol. I'm happy to leave it at that unless someone else has something to add.
Related
Android 6.0 Marshmallow’s introduces Adoptable Storage, a feature that allows use a SD Card as internal storage.
Is it possible to activate adoptable storage via ADB shell commands?
I managed succesfully perform this operation on my LG K8 LTE. I want to notice there are "500 xxx Unknown disk" errors problems, and give solution to avoid this. Solution is very simple.
Proper steps in ADB would be:
adb shell
sm list-disks
// HERE YOU GET YOUR DISK ID, SOMETHING LIKE "disk:179,64" - REMEMBER THOSE NUMBERS
sm set-force-adoptable true
// IN NEXT LINE, SIMPLY PUT THOSE NUMBERS AFTER "disk:" AND ALSO AFTER WORD "mixed" TYPE PERCENTAGE OF SPACE LEFT AS EXTERNAL, SO IN MY CASE:
sm partition disk:179,64 mixed 60
// IT TAKES TIME. BE PATIENT. WITH THIS LINE I TRANSFORMED WHOLE EXTERNAL SD INTO 40% OF INTERNAL AND 60% OF EXTERNAL
sm set-force-adoptable false
BANG! That's it! Now go to storage and usb, there click on internal part of SD and expand options, click on "use as internal" or something like that, last option, (I cannot see what was that because I already clicked it and everything works) apps are finally going on SD with OBB files! ;)
Have a good day!
I have done somewhat extensive research on this question online. I can tell you the steps, and they seem to work for everyone but me. Try them and let me know if they work for you.
Back Up your SD card, as it will be wiped.
If you don't already have it, download and install Java SE Development kit. The website is www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. I used version 8u101 for Windows x64.
If you don't already have it, download Android SDK Manager. The website is developer.android.com/studio/index.html. Scroll almost to the bottom where it has "Get just the command line tools" and select android-sdk_r24.4.1-windows.zip for Windows. When it downloads, extract all to a location where you want to keep the folder.
Open the Android SDK folder and run the SDK Manager. (If it fails to run, see question 14504325 in stackoverflow). Follow the instructions on www.howtogeek.com/125769/how-to-install-and-use-abd-the-android-debug-bridge-utility/ to get it up-and-running.
When you have the command prompt open per the how-to-geek website instructions, enter "adb shell"
Then enter "sm list-disks". This will return the name of your microSD card. The instructions I was following showed a disk labeled 179:160, but my computer showed the disks as 179,32. This is where I'm stuck.
Finally, enter "sm partition disk:179:160 private", where the numbers are the name of your disk from step 6, if you want to adopt your whole SD card as internal storage. Otherwise, enter "sm partition disk:179:160 mixed 25" where the last number is the percent of the card's space used for external storage. I have not been able to get this to work.
See http://www.modaco.com/news/android/heres-how-to-configure-adoptable-storage-on-your-s7-s7-edge-r1632/ for the original instructions.
P.S. I tried this on a Samsung Galaxy On5, so that might explain why it hasn't worked.
This has now been disabled on (at least) some Samsung tablets.
I have a galaxy tablet that has been running with a huge sd card formatted as internal storage.
I purchased another more recently and on this adb format command did not work (it just immediately returned to the command prompt).
I have had to do a factory reset on the older machine and now find that it too will not allow the SD card to be formatted as internal memory - it behaves just as the newer one does.
My guess would be that Google have updated android to 'respect' the settings of the suppliers UI.
This has (of course) completely messed up my system, as the backup/restore was based on main memory of over 100GB, not the 16GB the device actually has.
I've been trying to write a small program to copy a folder on my mac (10.10.3), containing a set of songs, into the music folder on my Galaxy S3 (GS3) when it is connected via USB. Clearly I could just use Android File Transfer (AFT), and copy the files in (manually), however this wouldn't teach me anything. My goal is thus to automate this act. Python seems like a good choice for this project, as it seems like mostly scripting (in fact a Bash script may suffice).
This should be simple, using a bash script like cp ~/../music_on_mac /.../music_target_on_android
However, the file structure of the GS3 doesn't show up in the finder (like you would expect from an ordinary USB drive). I can only see the file structure via Android File Transfer. From what I've read, this is expected behavior (I suppose due to formatting differences?). Thus I've been unable to find the target directory /.../music_target_on_android
My best guess (getting a bit out of my depth here), is that I need to copy the music folder, and then pipe it to AFT, and have AFT place it in/on top of the target Music folder on my GS3. Is this correct? If so, could anyone offer suggestions on implementing this? If not, alternative approaches or suggestions would also be appreciated.
I'd also note that I considered using ./adb push <local> <remote> to try to copy the files directly, however this pushed back that the device was read only. I'm also not familiar enough to find the proper directory on the GS3 (the one containing the target for the "Music" folder) using ./adb shell. There's also the added downside that in order to use a solution involving the ADT, one must have the ADT (which most people don't). Moreover, I want to keep it simple.
Research Update:
I've found that my phone will not show up in Finder because Google has disabled USB mass storage (aka mounting the phone as a disk) in favor of the Media Transfer Protocol (MTP). AFT is just an MTP client, needed because unlike Windows and Linux, OSX does not support MTP.
http://www.howtogeek.com/192732/android-usb-connections-explained-mtp-ptp-and-usb-mass-storage/
Based on tips, I've been able to implement an alternative based on creating an FTP server on my phone. Connecting to this gives me file system access and write privileges from my terminal, which is half the battle, however its quite slow. Thus I'd still like to find a way to automate instructions to Android File Transfer.
Edit: Below is my original question, written for OpenCV in Android. I was saving files correctly but the files were not showing up in My Computer on my laptop! Strange enough, they were showing up in Astro File Manager. See the answer for more details...
I have read/write permissions enabled. The 'cm' matrix is NOT null.
I am trying to check my images during my processing process to make sure they are being formed the right way.
Here is my C++ code in the android native environment:
imwrite("/storage/emulated/0/stackovernose.jpg", cm);
cm is a MAT file.
/storage/emulated/0 is hard-coded from Environment.getExternalStorageDirectory(); The file is created, succesfully (the inner If tree is activated) but I can't find it on my phone? I've used similar code in the past and sometimes it works, and sometimes it doesn't. This time it's not working at all. What am I missing?
On some newer devices (Moto X, Nexus), you must disconnect, restart, and re-connect your device in order for your files to refresh in My Computer. Optionally, you can download a file manager from the play store to see your files immediately after they are generated.
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
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/"