How to save RatingBar Rating?
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);
精彩评论