Java tutorial
//package com.java2s; import android.content.Context; import android.os.Build; import android.provider.Settings; import android.telephony.TelephonyManager; public class Main { /** * Unique ID of the Android device */ public static String ANDROID_ID; /** * Gets an unique device Id depending on the sdk version * * @param context * @return */ public static String getUniqueDeviceId(Context context) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } else { final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getDeviceId(); } } }