0

I have a SQLite Database in my Android app with a "Question" table, among others. That table contains "default" or "pre-loaded" data (in this case the questions asked by the app).

Some of its columns are "technical" or "internal" data to be used behind the scenes - like the number of points the question is worth, the type of user that may answer it, etc. - while others are textual data that are presented to the user (e.g. Title, Description, etc.).

Now, I intend to let my app be internationalization-friendly (translatable) so I'm thinking that:

  • Instead of following what seems to be the 'standard approaches' for multi-language DB design - either creating different columns for the translatable attributes (e.g. name_en, name_es, ...) or a separate table where each row represents a translation of the base object;

  • ...I could simply keep the values for those translatable attributes in my R.Strings resource and have my DatabaseHelper class fetch the text from there, by building the resource name based, for instance, in the question's ID (e.g. q1_name, q2_name, q1_description, ...). This way I could have several R.strings and the DB helper would read from the right one.

I'm a bit unsure about this approach and I'm curious if this is a bad practice and/or I'm missing any potential drawback.

  • Thanks for the tip but I already know that I can have multiple strings.xml files (and have now edited my answer to reflect that). The question is instead about whether or not there's any harm or undesired outcomes in using the strings.xml to store the values for the display attributes. – user1987392 May 12 '14 at 11:55
  • After the release of your app, is there any way for users to add additional questions to the database or to modify the questions being asked? Or can the questions only be updated by you? – Bart van Ingen Schenau May 12 '14 at 12:19
  • That's a good point as if the users were able to add content, my suggested approach could fail (unless I added a flag to drive if the title/description/etc. comes from the R.strings or DB, depending on whether it was created by the user or not). However, I'm expecting to be the only one to add content to that table. – user1987392 May 12 '14 at 12:29
0

I don't know much about Android standards but I am sure that creating different columns for the translatable attributes is cleary a very bad solution. You would have to alter your table each time you add a new language and if your application get translated in many languages, you will have to manage that.

The two other solutions are acceptable for me but I would chose the database option if you plan to create an "admin" interface where people could for example add question and solutions...

  • Right. I don't intend to have an "admin" UI to add questions, so I guess I can go with my suggested approach. I will wait a bit for other answers and if I don't see a better one I will accept this, thanks. – user1987392 May 12 '14 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.