Managing your properties

Loading and using properties

At start while calling startKoin function, you can check several ways to load external properties into Koin:

  • file (in src/main/resources, src/test/resources, assets/
  • parameters in startKoin() with properties parameter
  • environment properties with useEnvironmentProperties parameter

Then, you can get any property with getProperty(<KEY>) in your module or runtime component or inject with by property("key")

Writing properties

Runtime components and KoinComponents can also write properties with setProperty(KEY,VALUE)

Android bindings

You can bind any Android property to a Koin property with:

// bind R.string.server_url to Koin WeatherModule.SERVER_URL
bindString(R.string.server_url, WeatherModule.SERVER_URL)

Android/Koin property binding is available for int/string/boolean.