开发者

How to save RatingBar Rating?

开发者 https://www.devze.com 2023-03-16 20:42 出处:网络
I would like开发者_JS百科 to save the rating bar rating for the user. I was wondering is it possible i could save the value inside of the SQL database or is there a better way?You can use ratingBar.ge

I would like开发者_JS百科 to save the rating bar rating for the user. I was wondering is it possible i could save the value inside of the SQL database or is there a better way?


You can use ratingBar.getRating() to get the rating value (returns a float). This could indeed be saved to an SQL database, but I find it easier to use the preferences if you have a single rating to save.

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    preferences.edit().putFloat("rating", ratingBar.getRating()).commit();

And then you can retrieve the value using

    preferences.getFloat("rating", 0.0f);
0

精彩评论

暂无评论...
验证码 换一张
取 消