Suppose I am using some device to run the android program but now I wanted to know the device name which I m using through code.How can I get it.
Asked
Active
Viewed 4,434 times
2 Answers
2
public static String getDeviceName() {
String manufacturer = Build.MANUFACTURER;
String model = Build.MODEL;
if (model.startsWith(manufacturer)) {
return capitalize(model);
} else {
return capitalize(manufacturer) + " " + model;
}
}
private static String capitalize(String s) {
if (s == null || s.length() == 0) {
return "";
}
char first = s.charAt(0);
if (Character.isUpperCase(first)) {
return s;
} else {
return Character.toUpperCase(first) + s.substring(1);
}
}

Shivang Trivedi
- 2,182
- 1
- 20
- 26
2
Use this code to get the Device name:-
String deviceName = android.os.Build.MODEL;
System.out.println("Device Name--"+deviceName);

bakriOnFire
- 2,685
- 1
- 15
- 27