Reputation: 1249
I have an object method instead of static in java
object StaticMethods{
fun clearProgressPreferences(sp: SharedPreferences, level:String, test:String){
val edit = sp.edit()
edit.putInt(level+test+"array_size", 0)
edit.apply()
}
When i try to invoke it, i get the java.lang.reflect.InvocationTargetException
The same thing with companion object of any classes
Upvotes: 0
Views: 38
Reputation: 12118
If you want to make it static,just put @JvmStatic
annotation before your function & call :
StaticMethods.clearProgressPreferences()
If you want to access it as it is then use like this :
StaticMethods.INSTANCE.clearProgressPreferences()
Upvotes: 2