get Device Id from Secure.ANDROID_ID - Android Hardware

Android examples for Hardware:Device ID

Description

get Device Id from Secure.ANDROID_ID

Demo Code


//package com.java2s;

import android.content.Context;

import android.provider.Settings.Secure;

public class Main {
    Context mContext;//from   w ww .  j a v  a  2 s.  c  o  m

    public static String getDeviceId(Context mCm) {
        return Secure
                .getString(mCm.getContentResolver(), Secure.ANDROID_ID);
    }

    public String getDeviceId() {
        return Secure.getString(mContext.getContentResolver(),
                Secure.ANDROID_ID);
    }
}

Related Tutorials