Sign up ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I am interested in learning how to write to (and if possible, read from) a rooted Android device's clipboard.

I hope to do so using ADB over USB and I am not interested in installing any apps to help me do this, as this is something I plan on rarely doing.

Any suggestions or help guiding me in the right direction would be greatly appreciated.

share|improve this question

2 Answers 2

up vote 13 down vote accepted

Yes, you actually can do this. It's kind of kludgy looking when you inspect the clipboard, but it works just fine.

First off, you can inspect the current clipboard contents with service call clipboard 1 from an adb shell (or, without shelling in first, adb shell service call clipboard 1). It may start out initially blank after a reboot, for example:

# service call clipboard 1
Result: Parcel(
  0x00000000: 00000000 00000001 00000000 00000000 '................'
  0x00000010: 00000000 00000000                   '........        ')

You can put text into the clipboard using service call clipboard 2, which basically takes 3 parameters - two ints and the string you want to put on the clipboard:

# service call clipboard 2 i32 1 i32 0 s16 "Hi there"
Result: Parcel(00000000    '....')

To be honest, I'm not sure what the first two parameters are. One answer on Stack Overflow has suggested the first int is "number of items in the parcel" (one in this case) and that the second is the length of the string. However, I've used 0 for the second parameter and it works fine, and I can't find any documentation that matches up with this particular take that for what it's worth.

In any case, it's basically creating a Parcel object with 3 fields, then passing it into the clipboard. The clipboard then unpacks the Parcel and sets the string value passed in as the clipboard's contents. You can see this when you go to retrieve the value afterwards:

# service call clipboard 1
Result: Parcel(
  0x00000000: 00000000 00000001 00000000 00000008 '................'
  0x00000010: 00690048 00740020 00650068 00650072 'H.i. .t.h.e.r.e.'
  0x00000020: 00000000 00000000                   '........        ')

Similarly, if you long-press on a text entry field and hit "Paste" after doing this, you will get the text that was set via the call service clipboard 2 line above (and it will look completely normal).

(The above examples come from my HTC EVO, running CyanogenMod 7)

share|improve this answer
I can finally paste my WPA key and connect to my router :D. Thank you. – earthmeLon Feb 20 '12 at 22:50
@earthmeLon if you were just trying to find an easy way to copy your WPA key, then next time you might find it easier to do seomthing like email it to yourself and copy/paste from email, or copy a text file containing it onto your device over USB, then open and copy from there. There are other options like Wifi Keyboard that let you type (or paste) from a PC and have it appear on the phone. – GAThrawn Feb 21 '12 at 10:47
My WPA key is sensitive. It should not be broadcast over any non-local network EVER. Thanks for the suggestions @GAThrawn. I will find more use for this functionality eventually :D – earthmeLon Feb 21 '12 at 18:10
copying a file via usb is local – user24411 Feb 14 '13 at 7:10
Do you by chance know what's the equivalent for lollipop? This command worked in kitkat, but not in lollipop anymore – galets Apr 18 at 21:57

I used this methodology, and it worked fine in 4.x, but failed for me in lollipop. While looking for alternative solution, I found this:

it is not exactly as you wanted it, but for myself, most time I want to copy text to clipboard is because I want to paste it into password field.

as an additional bonus, here's my script (edited 2015-04-24 to allow spaces in text):


if [[ "$1" != "" ]]
    read -s -p "Enter text you want to insert: " TEXT

ESCAPED_TEXT=`echo $TEXT | sed "s/\s/\%s/g"`
adb shell input text "$ESCAPED_TEXT"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.