Redeem Now
Read More
Read now

Clipboard for copy and paste option in android


Everyone knows the importance of copy and paste in today’s life. Also in many scenarios you have to copy a particular text , image, link etc. in mobile devices as well. Android provide the copy and paste feature through the library of ClipboardManager and ClipData. You can use this library to copy and paste different types of data on your android devices.

For copy you have to make a instance of ClipboardManager and then put the data to be copied on ClipData object then android will put that data onto system wide Clipboard from where you can access that data anywhere in your device. So firstly lets make a ClipData object and add some random data in it like

Now your dummy text is copied to the clipboard you can add a OnLongClickListener on ant text or image then perform all these oprations inside listener. For image the URI is copied on the clipboard.

Now for pasting this dummy text or any other type of data currently in clipboard you have to again instantiate ClipboardManager and then get the data stored/ copied on the clipboard like

Now you have the copied text in String type variable test you can set it anywhere you want. You can again apply OnLongClickListener on any TextView or EditText and set the copied text over there by this method.

. . .


Add Your Comment

Be the first to comment.

Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again