I am creating a user based android application wherein each user will be registered with a unique id when he/she will be signing up for the first time. How do I do it?
            Asked
            
        
        
            Active
            
        
            Viewed 1,509 times
        
    -1
            
            
        - 
                    register with device unique id – Nisarg Jan 30 '16 at 10:30
- 
                    2http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id – Whome Jan 30 '16 at 10:33
3 Answers
1
            
            
        For Device id
String android_id = Settings.Secure.getString(getContext().getContentResolver(),
                    Settings.Secure.ANDROID_ID);
 
    
    
        Nisarg
        
- 1,358
- 14
- 30
- 
                    It's known to be null sometimes, it's documented as "can change upon factory reset". Use at your own risk, and it can be easily changed on a rooted phone – MilapTank Jan 30 '16 at 10:42
- 
                    But we can set constraint for null values , there will be no risk i guess for rooted devices too – Nisarg Jan 30 '16 at 10:49
- 
                    if we are making ANDROID_ID as primary key than same user can make more than one account from one device this is only risk :) – MilapTank Jan 30 '16 at 10:52
- 
                    Yea true , thank you for information means we can not overcome this problem right !! for rooted devices – Nisarg Jan 30 '16 at 11:02
- 
                    1No friend you can use other technique for this i have use in my project that you can see this https://gist.github.com/milaptank/25eddae25b59c643eb19 :) – MilapTank Jan 30 '16 at 12:02
- 
                    
1
            
            
        Starting with Java 5 there is a UUID (Unique identifier) class. So just do something like this:
UUID userId = UUID.randomUUID();
And you will have a Unique ID for that session that you can store.
 
    
    
        Gabriel Garcia
        
- 122
- 7
- 
                    If you actually check out the post time, they were published at the exact same moment. – Gabriel Garcia Jan 30 '16 at 13:41
 
    