Code example for ClipboardManager

Methods: getPrimaryCliphasPrimaryClip

    	protected Void doInBackground(Void... nothing){
    		Log.i(TAG, "Clipboard Monitor Background running");
    		ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
	    	if (clipboard.hasPrimaryClip()){	//Check that clipboard is not empty
	    		ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);	//Get item zero
	    		text =  item.getText();
	    		//Save to database 
	    	return null; 
    	protected void onPostExecute(Void nothing){
    		Context context = getApplicationContext();
			CharSequence toastText = getString(R.string.stuff_copied);
			int duration = Toast.LENGTH_SHORT;
Connect your IDE to all the code out there  Get Codota for Java