Open In App
Related Articles

How to Get the Device Information in Android?

Like Article
Save Article
Report issue

In the present world, sometimes we want to access the device information of the user to expand our business e.g. An e-commerce company may want to access the mobile’s brand of the user to provide (more specifically, to target the user for high/low price’s items) recommendation. We can find the device (hardware and software) information using Build Package in Android.

Step by Step Implementation

To get the device information follow these steps. We are going to implement it using the Kotlin language.

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language.

Step 2: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. 


<?xml version="1.0" encoding="utf-8"?>
        android:text="Your Device Info"
        android:textStyle="bold" />
        android:textSize="16sp" />


Step 3: Working with the file

Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail.


import android.annotation.SuppressLint
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.widget.TextView
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        val tvDisplay: TextView = findViewById(
        tvDisplay.text = getSystemDetail()
    private fun getSystemDetail(): String {
        return "Brand: ${Build.BRAND} \n" +
                "DeviceID: ${
                } \n" +
                "Model: ${Build.MODEL} \n" +
                "ID: ${Build.ID} \n" +
                "SDK: ${Build.VERSION.SDK_INT} \n" +
                "Manufacture: ${Build.MANUFACTURER} \n" +
                "Brand: ${Build.BRAND} \n" +
                "User: ${Build.USER} \n" +
                "Type: ${Build.TYPE} \n" +
                "Base: ${Build.VERSION_CODES.BASE} \n" +
                "Incremental: ${Build.VERSION.INCREMENTAL} \n" +
                "Board: ${Build.BOARD} \n" +
                "Host: ${Build.HOST} \n" +
                "FingerPrint: ${Build.FINGERPRINT} \n" +
                "Version Code: ${Build.VERSION.RELEASE}"



Last Updated : 15 Oct, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads