Set text and get text from clipboard [closed]

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.


ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 
clipboard.setText("Text to copy");
clipboard.getText();