VOOZH about

URL: https://www.geeksforgeeks.org/android/clipboard-in-android/

⇱ Clipboard in Android - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Clipboard in Android

Last Updated : 23 Jul, 2025

Android's Clipboard performs copying and pasting on different data types, such as text strings, images, binary stream data, and other complex data types. Clipboard does the copying and pasting operations within the same application and between multiple applications that have implemented the clipboard framework. Clipboard has a limitation on the number of clip objects it can hold at a time. The clipboard can hold only one object at a time. If an object is put on the clipboard, the previously held object on the clipboard is dropped. The clip object can take in three types of data:

  • Text: A string can directly be put into the clip object and then into the clipboard. We can then get the clip object from the clipboard and paste the string into the application's text or storage fields.
  • URI: It is used for copying complex data from the content provider. A URI object can be put into a clip object and then loaded onto the clipboard. To perform a paste operation, the clip object must be resolved into the source, such as a content provider.
  • Intent: An intent object must be created and put into a clip object and loaded onto the clipboard. Paste action, similar to the text, can be performed.

Step by Step Implementation

To make an application that stores some data into the clipboard and derives the data from it in Android, we follow the following steps:

Saving to Clipboard:

A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Kotlin language. 

👁 Clipboard in Android Sample GIF

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language.

Step 2: Working with the activity_main.xml file

Go to the activity_main.xml file which represents the UI of the application. Create an EditText where we shall supply the text to be saved in the clipboard, and a Button to perform the saving action. Below is the code for the activity_main.xml file.

Step 3: Working with the MainActivity.kt file

Go to the MainActivity.kt file, and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.

Output: Run on Emulator

Pasting from Clipboard:

A sample GIF is given below to get an idea about what we are going to do in this section.

👁 Clipboard in Android Sample GIF

Step 1: Working with the activity_main.xml file

Below is the code for the activity_main.xml file.

Step 2: Working with the MainActivity.kt file

Go to the MainActivity.kt file, and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.

Output: Run on Emulator

Comment
Article Tags:
Article Tags:

Explore