How to use sqlite as string resource instead of strings.xml for language?

334 Views Asked by At

I have two API. One is to send me a list of languages and the second is for getting a list of key/value strings. I want to use this key/value as a string resource in the android app, instead of a string.xml file.

For this condition I have decided to store all the key/value responses in SQLite and when user will change language use SQLite as a string resource.

is it possible? any other idea? good example?

1

There are 1 best solutions below

0
On

In My Previous Project we are also using SQLite Database to store label strings in 4 Languages.

For this we are applied two approach :

1.Write Simple Query to get only one LABEL(Language code, Key). its very easy and fastest way to set Label for the buttons message , title and other things.

2.When we have a long page having logical group of fields so we create query with group of keys and language with them.so its returns List of Labels with keys also we are using same text for key and Id for Views to easy to identify write label.

3.Also It is easy to maintain suppose one of the label text got changed so in next Network call we only update that particular label in Database with (key , language code) and its reflected over the screen.

4.One good things is that if we are using SQLite Database with Room, LiveData , View model and Data Binding its very easy to maintain all such thing.

5.This approach requires one time code and easy to expand , modify and maintainable from server side.