I have a function that displays the username. It works fine but I am getting this warning and I was wondering how to solve it.
Asked
Active
Viewed 138 times
2 Answers
0
Define the string in the strings.xml, do not hardcode it in the code. "Welcome, %s"
Then use it in the code:
getString(R.string.welcome_message).format(userProfile?.username)

Grela
- 96
- 2
0
Declare your string like this Welcome %1$s And when you want to use it
context.getString(R.string.welcome,userProfile?.username)

franvillacis
- 199
- 4