Device model in strings.xml?

229 views Asked by At

Hello guys!

I have got a problem, I want to make my app display the device name (if your [DEVICENAME] is rooted or not) in the strings.xml, I have already tried many things, but nothing really worked.

Please tell me how to do that! It should work in Toasts made with MainActivity.java.

2

There are 2 answers

2
siriscac On BEST ANSWER

In your strings.xml,

<string name="device">if %s is rooted or not.</string>

And in your Activity

getString(R.id.device, android.os.Build.MANUFACTURER + android.os.Build.PRODUCT);
3
Gaëtan On

You can do it as follow.

In your strings.xml:

<string name="device_rooted">if your %s is rooted or not</string>

And in Java:

context.getString(R.string.device_rooted, android.os.Build.MODEL);