https://kotlinlang.org logo
s

Steve

06/16/2020, 9:11 PM
how does one generally expose an app configuration to the rest of the app? Specifically, I do need part of it for my network requests, as the config is what provides the keys
u

ursus

06/16/2020, 9:48 PM
DI? public consts?
j

Joost Klitsie

06/17/2020, 9:50 AM
I think it is totally depending on where you store the keys. For example, they can come from the BuildConfig, Strings.xml or even hardcoded. In cases, I would advise a wrapper class so you can inject your constants provider where you need it and also make it testable. Also, you might wanna store some of these keys on the backend side so people cannot dig through your APK looking for unsecured api keys. To have such a key/constant/whatever provider would in any case abstract away the logic, making sure that if you ever change the place where they are stored the rest of your code is not affected
2 Views