Answer the question
In order to leave comments, you need to log in
How to overwrite data from a row in SQlite?
Good afternoon.
Help me to understand.
I have an SQlite table with a column "musicSwitch" in my application.
In this column, I need only one line, which will store either 0 or 1, so that when loading, the application determines whether background music should be turned on or not.
Accordingly, when the button is clicked, the following is done:
switch (buttonpress)// определяет включен или выключен звук сейчас
{
case 1: // если включен
buttonpress=0;
contentValues.put("musicSwitch", 0);//пишет в таблицу строку со значением 0
stopPlayer();//останавливает плеер
break;
case 0: // если выключен
buttonpress=1;
contentValues.put("musicSwitch", 1);//пишет в таблицу строку со значением 1
play();// включает плеер
break;
}
database.insert(DBHelper.TABLE_SETTING, null, contentValues);
Answer the question
In order to leave comments, you need to log in
What for it in general to write to a DB? Especially since you're obviously doing it on the mainstream. Do not do it this way. Write in shared preferences.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question