Reputation: 31
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?
Upvotes: 3
Views: 1185
Reputation: 817
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.
Upvotes: 2