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
Can you add List<MyClass>
example to README?
#2
Comments
I am checking this out, but my first comment, as a Kotlin teacher, is that you can optimize class User(var name: String, var age: Int = 0)
val users = List(6) { i -> User("Name$i", i) } |
I cannot reproduce your problem. I've implemented tests for this case. If you will still have this problem then place, give me more details. First of all, presented users.toString() should produce something like this:
Simple Kotlin solution is to use data class User(var name: String, var age: Int = 0) Also Gson funcions are not working in my project. What Gson version are you using? |
I found something. I changed User class like this data class User(var name: String, var age: Int = 0) and add val users = List(5) { i -> User("Name$i", i) }
AppPreference.users = users
Log.i("###", "" + AppPreference.users)
// => [User(name=Name0, age=0), User(name=Name1, age=1), User(name=Name2, age=2), User(name=Name3, age=3), User(name=Name4, age=4)] but after app restart Log.i("###", "" + AppPreference.users)
// => [{age=0.0, name=Name0}, {age=1.0, name=Name1}, {age=2.0, name=Name2}, {age=3.0, name=Name3}, {age=4.0, name=Name4}] This is my build.gradle
|
This is quite wired. I would expect from Are you sure that you are saving the value before obteining it? Because otherwice you may still operate on some old data that were saved before. If you are not sure then please change |
https://github.com/susemi99/TestKotlinPreference |
Please watch this video. |
I am really sorry, you are right. I improved test so it is now checking presented case. I also fixed this problem in version 1.51 |
And thank you for your contribution :) |
Thank you very much 👍 |
I'm using Android Studio 3.0 + kotlin.
Please add some more detailed instructions for beginners.
The text was updated successfully, but these errors were encountered: