Here you can find the source of set(Context context, String value)
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void set(Context context, String value)
//package com.java2s; import android.annotation.TargetApi; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.os.Build; public class Main { @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void set(Context context, String value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipboardManager clipboard = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("text", value); clipboard.setPrimaryClip(clipData); } else {//from w w w . ja v a 2s .c o m ClipboardManager clipboard = (ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText(null, value)); } } }