Android Question Save Options

Douglas Farias

Expert
Licensed User
Longtime User
what the best way to save options in the dirassets

for exemple

press option button

option button show
select a background color

you select red

when you exit from app save this color on a txt file in dirassets
when you open app again read this txt and set background = red

*-*

my config need 4 itens

""""""""""""""""""""""""""""""""""""
txtfile

Sound=True or false
background=Color 5 or 6 colors i go make
menucolor=Color 5 or 6 colors i go make
language= english or portuguese

i need read this configs when open the app *-*

the user can change this configs in the app and save when open app again it already seted *-*

can someone show me a simple?
 

derez

Expert
Licensed User
Longtime User
A simple way to save the 4 parameters is a map with each parameter as a key and its value - the value.
The map is saved to a file using randomaccessfile , writeobject.
You cannot change files in dirassets so the application should do the following when starting :
1. check if the file exists in a directory in another place (for example - dirrootexternal or dirinternal).
2.If the file exists - it is not the first activation - read the file (using readobject) and read the parameters from the map.
3.If the file does not exist - first activation - create the directory and copy the file from dirassets, then read the file and the parameters from the map.
 
Upvote 0
Top