-1

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.

The function and warning

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
dica400
  • 3
  • 4

2 Answers2

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