Here, in what an essence: I practice writing applications for an android and faced the following problem. I have a ListView , when I click on any item in this list, the background of the adapter changes. It is necessary that this change be saved after the application is restarted. In some places, it was suggested that for this you need to save changes in the database, but I don’t understand how to do this, although there is some basic knowledge of working with SQLite . I do not count on the finished code, but I would be very grateful for the example.

  • hmm, thanks, i hear for the first time from such a thing. - Vladimir Fedulkin

1 answer 1

Bd is too trump for this task, you need to use SharedPreferences .

  • The color is encoded long 'om - for example, red is #FF0000 . It should be recorded in SharedPreferences long and all - Barmaley
  • I honestly do not quite understand how to save the color for the clicked item. I'm sorry. - Vladimir Fedulkin
  • It turns out that in place of the color definition: (((TextView) view) .setBackgroundColor (Color.parseColor ("# 757070")); I have to substitute a variable containing the actual color, and previously defined. And then in onStop somehow save that the clicked item has a background with certain text. How? - Vladimir Fedulkin
  • if you have only 2 of them there, you can save in the database boolean ie if true - displays one background, if the fall is different, if the option is larger and the user has the opportunity to choose the color himself (which I doubt) then store long, well, and if there are only a couple of points, then just store the item's number and substitute it backing Conclusion - read about SharedPreferences. - Gorets
  • one teach, materiel, if that is not clear - write =) - Gorets