Java tutorial
//package com.java2s; /* * Copyright (C) 2010-12 Ciaran Gultnieks, ciaran@ciarang.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.util.Locale; public class Main { private static final String[] androidVersionNames = { "?", // 0, undefined "1.0", // 1 "1.1", // 2 "1.5", // 3 "1.6", // 4 "2.0", // 5 "2.0.1", // 6 "2.1", // 7 "2.2", // 8 "2.3", // 9 "2.3.3", // 10 "3.0", // 11 "3.1", // 12 "3.2", // 13 "4.0", // 14 "4.0.3", // 15 "4.1", // 16 "4.2", // 17 "4.3", // 18 "4.4", // 19 "4.4W", // 20 "5.0" // 21 }; public static String getAndroidVersionName(int sdkLevel) { if (sdkLevel < 0) { return androidVersionNames[0]; } if (sdkLevel >= androidVersionNames.length) { return String.format(Locale.ENGLISH, "v%d", sdkLevel); } return androidVersionNames[sdkLevel]; } }