0

I am developing an application in which I have to put as well as get some files from Computer(i.e Windows system) using USB.

I searched the web but didn't get anything helpful. I have an idea about command line so I am able to do this by using commands like

./adb -s emulator-5554 pull /sdcard/juned.jpg c:/user/juned/images/

It will copy juned.jpg file in specified directory of system, but is it possible to run same command programmatically ?

Till now I got one sample application in Android Samples named AdbTest which is available under /root/android-sdks/samples/android-18/legacy/USB/ directory, I have tried to compile that application but it shows nothing.

In that application under xml directory device_filter.xml file is there. In that file

<resources>
    <usb-device class="255" subclass="66" protocol="1" />
</resources>

What value should I provide to make it working with my device ?

And is it possible to run adb commands from indide an application programmatically?

Edit

So far I came to know that, adb command can not be executed in non rooted devices, so is there any other way to transfer files using USB ?

halfer
  • 19,824
  • 17
  • 99
  • 186
Juned
  • 6,290
  • 7
  • 45
  • 93
  • You might require root acces to do this from your app – Metalhead1247 Sep 14 '13 at 13:06
  • @Metalhead1247 is there any solution for non rooted devices ? – Juned Sep 14 '13 at 13:26
  • This has nothing to do with root. Rather the issue is that you need some sort of file server on the PC to somehow make files available upon request from the device. **adb does not provide that** - it only takes requests from the PC end. – Chris Stratton Apr 01 '14 at 19:51

1 Answers1

-2

Its not possible for Devices which are not rooted

Since to run your command it requires Su permission (Super User) .

Your command will be system/bin/ Su / -command

non rooted device don't have access to system/bin/ Su

you can root your emulator by Installing Superuser.apk

or try How to get root access on Android emulator?

Community
  • 1
  • 1
Metalhead1247
  • 1,978
  • 1
  • 17
  • 28
  • 1
    No, it has nothing to do with root, but rather that the adb push/pull commands have to be issued from the PC, not from the Android device. You are confusing this with various other *shell* commands and operations which are permitted to adbd's "shell" (or on the emulator "root") userid, and not to applications. But push and pull are not *shell* commands run *via* adb, but rather *development system adb commands*. – Chris Stratton Jan 06 '14 at 16:23