1

I am trying to use a previously created database following the tutorial:

http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

I plan to use the database for storing questions for a trivia-like game. With the basic design of one table:

CREATE TABLE QUESTIONS (
 answer TEXT,             --text for answer
 create_by_user NUMERIC,  --boolean flag, true if question created by user
 _id INTEGER PRIMARY KEY, --required by Android
 l10n TEXT,               --ISO 3-letter code for localization
 question TEXT            --text for question
);

And using the field l10n for l10n/i18n purposes, but I am not sure about how Android uses android_metadata table. In the tutorial a row with "en_US" value is inserted,

  1. Is this table a sort of built-in l10n used by Android?
  2. It would be advisable to use the table android_metadata for l10n instead of my own l10n field?
  3. What if I want the database to store different languages data and to give the option to the user to retrieve questions from different languages?
  4. Do I need or is it better to have one database per language?
BrettAdamsGA
  • 774
  • 4
  • 12
  • 24
viridis
  • 167
  • 10

1 Answers1

2

Android updates that field each time you open the database to the current default locale. That should be the system language unless you change the default in your app.

SQLiteDatabase#openDatabase

db.setLocale(Locale.getDefault());

It should be save to use that field but I have never tested it.

The purpose of that table is AFAIK to allow you to use COLLATE LOCALIZED in your statements - or not if you specify NO_LOCALIZED_COLLATORS

If you want to have a database of texts in different languages then consider using your own table of languages maybe as foreign key to you text table.

Community
  • 1
  • 1
zapl
  • 60,293
  • 10
  • 115
  • 141