Radhakrishna Rayidi
Radhakrishna Rayidi

Reputation: 520

Clearing Clipboard Data in Android

I'm trying to clear the Clipboard data in android as follow but its not clearing it.

ClipboardManager clipman = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipman.setPrimaryClip(null);

Any ideas ?

Upvotes: 5

Views: 5180

Answers (1)

sarnabtech
sarnabtech

Reputation: 496

Since API 11 ClipboardManager (as old ClipboardManager class is deprecated.)

ClipboardManager clipBoard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData data = ClipData.newPlainText("", "");
clipBoard.setPrimaryClip(data);

Upvotes: 19

Related Questions