Set text and get text from clipboard

Lukap picture Lukap · Jul 11, 2011 · Viewed 28.1k times · Source

In Android, I need some code to "get text" and "set text" in the clipboard.

For example I want to put "asd" in memory and after that paste it from clipboard.

Answer

Chirag picture Chirag · Jul 11, 2011
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
clipboard.setText("Text to copy");
clipboard.getText();