Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean cannot be cast to java.lang.String #132

Open
pranavlathigara opened this issue Feb 22, 2019 · 3 comments
Open

Boolean cannot be cast to java.lang.String #132

pranavlathigara opened this issue Feb 22, 2019 · 3 comments

Comments

@pranavlathigara
Copy link

I have getting error while fetching boolean value in kotlin

val isAutoStart : Boolean? = PrefInstance.get(context)?.get(Constants.PREF_SERVICE_IS_ALERT,Boolean::class.java ,false)

Error Log

java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:225)
at com.github.pwittchen.prefser.library.Prefser.get(Prefser.java:266)
at com.github.pwittchen.prefser.library.Prefser.get(Prefser.java:239)

@pwittchen
Copy link
Owner

Hi @pranavlathigara,

Thanks for reporting this issue. I'll have a look on that.

Regards,
Piotr

@ubuntudroid
Copy link
Contributor

@pranavlathigara Fix is simple: just use Boolean::class.javaObjectType instead of Boolean::class.java and you should be set.

@pranavlathigara
Copy link
Author

pranavlathigara commented May 20, 2019

ok let me try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants