Java tutorial
//package com.java2s; import android.content.Context; import android.preference.PreferenceManager; public class Main { private static final String PREF_ADV = "pref_advertising_key"; public static final boolean hasAdvertisingID(Context c) { try { if (PreferenceManager.getDefaultSharedPreferences(c).contains(PREF_ADV)) { return true; } } catch (Exception e) { } return false; } }