Getting files to/from android phone

31,469

Solution 1

As I wrote in this thread, there are several solutions.

Given that you don't have a rooted phone, you can't install Samba Filesharing and have traditional samba shares on your phone.

But looking at this thread, it seems that ASTRO File Manager plus its SMB Module can work even without root access (not tested by me, can't confirm). AirDroid could be another alternative to test.

Solution 2

Pre-requisites

First, install the necessary packages:

sudo apt-get install mtp-tools mtpfs

A bit of elbow grease

Connect your Android phone to your computer. On your phone, open up the notification drawer, and click on USB Connection type. Make sure that MTP is selected.

MTP Mode

Now, run these commands on Ubuntu:

mtp-detect | grep idVendor
mtp-detect | grep idProduct

Note down the numbers written in front of idVendor and idProduct. You'll need those later on.


Now, run this command:

gksu gedit /etc/udev/rules.d/51-android.rules

A Gedit window should open up. Type this text in it, all in a single line:

SUBSYSTEM=="usb", ATTR{idVendor}=="VENDORID", ATTR{idProduct}=="PRODUCTID", MODE="0666"

Replace VENDORID with the idVendor you had noted down earlier. Similarly, replace PRODUCTID with the idProduct you had noted down.

Save and close the file.


Disconnect your phone and run these commands:

sudo service udev restart
sudo mkdir /media/androiddevice
sudo chmod a+rwx /media/androiddevice
sudo adduser yourusername fuse

Replace yourusername with your Ubuntu user name. Now, run this command:

gksu gedit /etc/fuse.conf

In the Gedit window, remove the # at the beginning of the last line (the one that begins with #user_allow_other). Close and save the file.


Restart your computer, and then run these three commands:

echo "alias android-connect=\"mtpfs -o allow_other /media/androiddevice\"" >> ~/.bashrc
echo "alias android-disconnect=\"fusermount -u /media/androiddevice\"" >> ~/.bashrc
source ~/.bashrc

Reconnect your phone, make sure it's still in MTP mode, and then run this command:

android-connect

Ta-dam!

You may now browse your Android phone's contents using Nautilus. Just fire up the file manager, and then in the side bar click on your phone's name to browse your phone's filesystem just like you would with a USB stick. You can add, remove and modify files just like a normal file system.

Phone filesystem


You might have noticed, however, that you cannot use the Nautilus eject icon to disconnect the phone. Instead, to safely remove the phone, you need to run the command:

android-disconnect

From now on, you will need to run android-connect to mount your phone and then android-disconnect to safely remove your phone. Everything else should be handled automatically.

Note: These two commands won't require root permissions to run. All users who are members of the fuse user group should be able to run these commands without root access.

You're done

That's it! You've successfully connected your Ice Cream Sandwich phone to your Ubuntu computer.


Source: OMG! Ubuntu!

Share:
31,469

Related videos on Youtube

wim
Author by

wim

Hi from Chicago! Python dev with interest in mathematics, music, robotics and computer vision. I hope my Q&A have been helpful for you. If one of my answers has saved your butt today and you would like a way to say thank you, then feel free to buy me a coffee! :-D [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*

Updated on September 18, 2022

Comments

  • wim
    wim over 1 year

    I am having trouble to access the filesystem on my phone (it's a samsung / google galaxy nexus). It just worked in previous version of Ubuntu, but now it appears empty whether it is mounted with MTP or PTP. I have followed a few guides on building and reinstalling libmtp etc without success. This answer did not help for me, either, and gMTP just hangs when I click the connect button. I know I can use wifi e.g. airdroid to access my photos, but this is too slow and a bit clumsy for me, and downloaded photos lose their original timestamps.

    Has anyone had success connecting to this phone on 12.04 ??

    • Sanam Patel
      Sanam Patel over 11 years
      Do any of the answers here help?
    • wim
      wim over 11 years
      nope ` ` ` ` ` `
    • wim
      wim over 11 years
      just tried, my device doesn't show up in banshee
    • Andrews Kalinovski
      Andrews Kalinovski over 11 years
      I had exaclty the same problem, pls if you found some solution publish it here. Thanks.
    • wim
      wim over 11 years
      no solution yet, i'm still limping along with wifi/airdroid. i will start a bounty.
    • wim
      wim over 11 years
      no, my phone is stock as a rock
    • Karthik T
      Karthik T over 11 years
      Cant you use mass storage mode? In Galaxy S2 i find the option under Settings->Wireless & network - More.... -> Usb utilities.
    • TardisGuy
      TardisGuy over 11 years
      Did you disable ADB (usb debugging) in dev- options?
    • wim
      wim over 11 years
      i've attempted with that enabled and disabled
    • SirCharlo
      SirCharlo over 11 years
      Check this out, as well.. Interesting script.
  • wim
    wim over 11 years
    I have already tried the OMGubuntu guide and it did not work properly for me
  • SirCharlo
    SirCharlo over 11 years
    What didn't work? Give details.
  • david6
    david6 over 11 years
    Can anyone suggest a fix for the 'connect'/'disconnect' issue?
  • wim
    wim over 11 years
    trying to browse on the mounted share just hangs .. and the only way to unfreeze it i've found is to unplug the cable
  • merveotesi
    merveotesi almost 10 years
    To have this work, mtp-detect must return some device, am i wrong? @SirCharlo
  • user.dz
    user.dz about 9 years
    @merveotesi, use sudo or run as root for mtp-detect. Regular user listed nothing for me.
  • iamgoddey
    iamgoddey about 7 years
    this is madness