2

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?

2
  • I would create a new Class which load all Strings on languageChange/Application Start from the database and set them programmatically during view creation. Commented Nov 26, 2018 at 8:52
  • @JohnDoe can you give me an example? or yo have put it on GitHub? Commented Nov 26, 2018 at 8:59

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.