Skip to content Skip to sidebar Skip to footer

The Way To Change Database Helper To Support Multiple Languages?

This is my dbhelper code. I want to ask whether it is possible to support multiple language in this database? Is there a need to use google translate api or should I create another

Solution 1:

Yes you can use the same database SQLite always stores text data as Unicode, using the Unicode encoding specified when the database was created. The database driver itself takes care to return the data as the Unicode string in the encoding used by your language/platform.

Internally sqlite encodes all strings either in UTF-8 or UTF-16 (there is a per-database option), but since it always converts them as needed (to one or other for comparison and to/from java.lang.String in the API), you don't even need to care.

In your database table you can add different columns for the language strings for different languages and fetch data from that particular column only.

On your App you can provide the option for user to change the language. At that time you can change the column according to the chosen language and do add/edit action on that column only.

Solution 2:

Instead of creating a separate database, you're probably better off adding another column to the table indicating language and just storing the localized strings in the same table.

Post a Comment for "The Way To Change Database Helper To Support Multiple Languages?"