Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANDROID - Get persistent device identifier (UUID)

I need a device identifier that persists after the app is uninstalled and reinstalled. I know that UUID class provides an identifier with the method

String uniqueID = UUID.randomUUID().toString();

but Android guideline is unclear about its scope and persistence. In next paragraph it says:

The Android Operating system offers a number of IDs with different behavior characteristics and which ID you should use depends on how those following characteristics work with your use-case. But these characteristics also come with privacy implications so it's important to understand how these characteristics play together.

Scope

Identifier scope explains which systems can access the identifier. Android identifier scope generally comes in three flavors:

Single app. the ID is internal to the app and not accessible to other apps.

Group of apps - the ID is accessible to a pre-defined group of related apps.

Device - the ID is accessible to all apps installed on the device. The wider the scope granted to an identifier, the greater the risk of it being used for tracking purposes. Conversely, if an identifier can only be accessed by a single app instance, it can’t be used to track a device across transactions in different apps.

Resettability and persistence

Resettability and persistence define the lifespan of the identifier and explain how it can be reset. Common reset triggers are: in-app resets, resets via System Settings, resets on launch, and resets on installation. Android Identifiers can have varying lifespans, but the lifespan is usually related to how the ID is reset:

Session-only - a new ID is used every time the user restarts the app.

Install-reset - a new ID is used every time user uninstalls and reinstalls the app.

FDR-reset - a new ID is used every time the user factory-resets the device.

FDR-persistent - the ID survives factory reset.

Resettability gives users the ability to create a new ID that is disassociated from any existing profile information. This is important because the longer, and more reliably, an identifier persists (e.g. across factory resets etc.), the greater the risk that the user may be subjected to long-term tracking. If the identifier is reset upon app reinstall, this reduces the persistence and provides a means for the ID to be reset, even if there is no explicit user control to reset it from within the app or the System Settings.

But I don't know how to get these identifiers, choosing my scope and persistence. Thanks

like image 962
leodev Avatar asked Nov 08 '22 13:11

leodev


1 Answers

I am using this:

String DeviceId = Settings.Secure.getString(c.getContentResolver(), Settings.Secure.ANDROID_ID);

Look this thread: Is there a unique Android device ID?

like image 124
David Avatar answered Nov 15 '22 06:11

David