I was told to store all strings needed for the applications in the .properties (so that future app localizations are easier to maintain) file which I did Now I have to alter some of them so they contain some variables inside of them for example string "hey, you have a new message" should now be "hey, , you have a new message from " and the string should still be stored in the .properties file
What I have now:
@Configuration
@ConfigurationProperties(prefix = "fcm.msg")
@PropertySource("classpath:notification.properties")
class FCMConfig {
lateinit var newMessageBody: String
here is the way-
store string data in a properties file
new-message-body = "Hey, you have a new message"
then where you want to use that string then just use this
@Value("${new-message-body}")
private String message;
Then you can use the message variable anywhere in that class.
if you want do not want to create any variable then just
System.out.println(@Value("${new-message-body}"));
在 kotlin 中你可以这样做
var variable_name:String=getString(R.string.newMessageBody)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.