How can I read from and write to my Galaxy Nexus phone, using MTP over a USB cable in python? I'm on a windows 7 computer.
4 Answers
Calibre, a popular ebook management program, has python and C source code to transfer files over an MTP connection. http://code.google.com/p/calibre-ebook/downloads/list
Simply connecting a USB cable between the phone and computer should work.
It may be necessary to enable MTP transfers in the settings menu on your phone. The menu selection location is likely to be different on different versions of android and different phone models. Try a google search for "galaxy nexus enable mtp". Make sure to include your android and phone version in the search.
Make sure it is a good quality USB cable. Poor quality cables will not make a good connection and therefor not work reliably.
A file management dialog comes up immediately on my desktop after hooking up a usb cable between my phone and laptop showing both the phone internal storage and SD card. This allows me to transfer files both ways directly to the phone SD storage (Linux Mint <-> LG Android ver. 5.1)
Note that it is also possible to transfer files using Bluetooth.
After establishing a connection, you would need to find the device name. Then it would be possible to open the device using standard python file constructs, i.e. popen(), etc.