How can I get the current Android SDK version(1.5, 1.6, 2.0, etc.) programmatically?
            Asked
            
        
        
            Active
            
        
            Viewed 7.4k times
        
    76
            
            
        - 
                    2Please edit the title of your question. Like "Retrieve android sdk version" – OneWorld Dec 09 '10 at 13:19
- 
                    I'd like the answer to this as well. I'm not at the point where I can run tests so I can't print any constants out. I downloaded it about a month ago and can't find the version number. – Adamantus Mar 22 '12 at 14:10
2 Answers
118
            The String Build.VERSION.RELEASE will give you the user-visible version string (i.e 1.5, 1.6, 2.0), while Build.VERSION.SDK_INT will give you a value from Build.VERSION_CODES that would be better to use if you want to compare against it programatically.
 
    
    
        Ross Rogers
        
- 23,523
- 27
- 108
- 164
 
    
    
        Erich Douglass
        
- 51,744
- 11
- 75
- 60
- 
                    26Note that Build.VERSION.SDK_INT is only available on Android 1.6 and newer. Build.VERSION.SDK will work on all Android releases, including 1.5. However, once you elect to drop 1.5 support, switching to SDK_INT is a good idea. – CommonsWare Dec 10 '09 at 19:10
- 
                    2
- 
                    The ActionBar compat lib uses the Build.VERSION_CODES.ICE_CREAM_SANDWICH constant and it doesn't crash on the 1.6 emulator. How can this happen? – jakk Sep 08 '12 at 20:36
25
            
            
          StringBuffer buf = new StringBuffer();
    buf.append("VERSION.RELEASE {"+Build.VERSION.RELEASE+"}");
    buf.append("\\nVERSION.INCREMENTAL {"+Build.VERSION.INCREMENTAL+"}");
    buf.append("\\nVERSION.SDK {"+Build.VERSION.SDK+"}");
    buf.append("\\nBOARD {"+Build.BOARD+"}");
    buf.append("\\nBRAND {"+Build.BRAND+"}");
    buf.append("\\nDEVICE {"+Build.DEVICE+"}");
    buf.append("\\nFINGERPRINT {"+Build.FINGERPRINT+"}");
    buf.append("\\nHOST {"+Build.HOST+"}");
    buf.append("\\nID {"+Build.ID+"}");
    Log.d("build",buf.toString()); 
 
    
    
        Richa
        
- 3,165
- 1
- 22
- 26
 
    