Skip to main content

Getting unique device id of an app user

Hello, here is a piece of code that can used in the development of an android app to get the unique device id

  • Step 1. Make sure to include the following line of code in the import/header section of the MainActivity.java file.


import android.provider.Settings.Secure;


  • Step 2. Define a private variable and get the unique ID with the following line of code


private String DeviceID = Secure.getString(getContext().getContentResolver(),Secure.ANDROID_ID);

Comments