Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Getting Clipboard Data Item List

Tags:

android

I want to get all the Clipboard Data Items on the device. By the following code, I can get only the recent Clipboard data.

myClipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);    
ClipData abc = myClipboard.getPrimaryClip();
ClipData.Item item = abc.getItemAt(0);
String text = item.getText().toString();

How can I get complete list of saved Clipborad Data as we see on the device?

like image 365
andro devlop Avatar asked Dec 07 '25 22:12

andro devlop


1 Answers

Use getItemCount() method to obtain the number of items.

Then use the getItemAt() method to fetch the items one by one using a loop.

Example:

int n = abc.getItemCount();
for(int i=0; i < n; i++)
{
    ClipData.Item item = abc.getItemAt(i);
    String text = item.getText().toString();
}

This usually works well with DragEvent.

like image 143
Ayan Avatar answered Dec 11 '25 19:12

Ayan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!