Question

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.

Was it helpful?

Solution 3

One way to do this would be to install ADB (android debugging bridge, part of the SDK) and launch it as a child process from python. ADB can be used to, among other things, read from or write to, an android device.

OTHER TIPS

I'm also looking for the same thing. There seems to be pymtp for cross-platform and wmdlib for Windows.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top