Answer the question
In order to leave comments, you need to log in
Java / Kotlin: why can't this be done?
Why, for example, can't I let the user enter any arbitrary value, and then find such a value and give a decryption?
<resources> // это в values/strings.xml
<string name="bomba">z2df21ffg231ffz</string>
</resources>
// это в MainActivity.kt
var userInputValue = "bomba"
var secretKey = R.string.userInputValue
Answer the question
In order to leave comments, you need to log in
It is possible to get an integer identifier from a string, but this is unproductive, so use with caution.
UPD:
You should not do this until you are one hundred percent sure of what you are doing. It is better to reconsider the approach to the solution.
val resId = context.resources.getIdentifier("bomba", "string", packageName)
if (resId != 0) {
val secretKey = context.getString(resId)
// ...
}
HashMap<String, String> map = new HashMap<String, String>();
map.put("car", "drive");
map.put("boat", "swim");
map.get("car")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question