2

I used device information to create unique ID for android device but after i read Security Tips of google, want to change it somehow.

Quote from Google:

If it's possible to design your application in a way that does not require any permissions, that is preferable. For example, rather than requesting access to device information to create a unique identifier, create a GUID for your application.

How can i have a Unique ID for a Device that doesn't change next time app runs or device reboot?

2 Answers 2

2

You can use below method:

Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)

that returns unique android id. and don't need any permissions.

Also you can check this link.

Sign up to request clarification or add additional context in comments.

4 Comments

Settings.Secure.ANDROID_ID is indeed device info!
oh, i see. you are right but i think it isn't unique and there is a small chance that 2 android IDs be the same. and also: When a device has multiple users (available on certain devices running Android 4.2 or higher), each user appears as a completely separate device, so the ANDROID_ID value is unique to each user.
But during factory reset, this ID will get changed right ?
Maybe @Firnaz !!! Also it's known to be null sometimes and documented as "can change upon factory reset". Use at your own risk, and I should say it can be easily changed on a rooted phone
0

you can use IMEI number which is unique to every phone but you need to ask

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

during runtime above api 23 and above.

2 Comments

so what do you think about google post? is it possible to have unique ID without problem and not using permissions?
using Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID) can give you unique id without having to ask for permission but from what i know, this value may change upon factory reset.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.