Is it possible to use RealTimeDataBase from google to set content depending on the device's language?
Right now I have a different string.xml for this, but I would like to show this content with help from database from google.
For example, in a description of main screen shows content in English for english users, in russian for russians and so on, but taking this info from RealTimeDataBase, anyone knows how to do it?
You may store your content under the language node in the database. For example:
- English:
- - content1
- - content2
- French:
- - content1
- - content2
So you can get the device language and query the database with that parameter for the child. But you should handle the case where you don't have the content in the device's language.
Related
I have an app in android that handles reporting about classes taken.
I have a edittext that is for entering the teacher's name, but there is a possibilty that there are more then one teacher.
I want to put all the names in the same edittext, similar to how its on gamil -
where you send a mail in gmail, you can enter multiple addresses (multiple values).
Best would be to have an autocompletetextview that will enalbe multiple names (values) in it, and the user can choose between pre-defined name options.
any ideas??
thnaks
Yes there is something you need.
You can use MultiAutoCompleteTextView from android widgets.
but here is more customizable version of it check this link TokenAutoCompleteTextView
It is same like gmail bubbles.It extends MultiAutoCompleteTextView from android widgets.
Hope it will help.Thanks
Hi i plan to develop an android application for English and Spanish Languages.For that we store data in Sq lite Database.without depends on the device language.
Application contains List of long text values stored in sq lite database and data retrieved from the db and shown in list view.how can i store different languages data in sq lite and how to retrieve and display in view based on language selection.
You could create a table in sqlite that contains nodes as one column and two other columns that contains the spanish version of the same and English version. Like:
ID NODE SPANISH ENGLISH
1 LOGIN S-LOGIN LOGIN
use :
Locale current = getResources().getConfiguration().locale;
to get the current locale, google a little bit to find out how to get the current language selection.
In the onResume method of the activity:
1. Check the current locale
2. Based on the current locale, fetch the strings for the labels and views
3. SetText to the views using the strings that you obtain
And that's it.
I hope this much clue helps!
just for curious, i got a question!
My app is almost ready.. I have implemented bilingual (English/Tamil) when users select thr preferred language in Settings then whole app gets converted into that language (i used custom Locale). Everything works fine.
My question is, Can we do the same to SQlite database? which fetch data automatically based on locale from table
"country-en"or"country-ta" ? is there any way? i heard that thr is a method SQLiteOpenHelper.onConfigure(setLocale()); to set locale in sqlitedatabase. i want to know how it works!
The method you describe above is not related to language localization for the client. It's related to locale options on the database (for example how to treat string comparisons with accented characters).
Anyway, if you think of it... what does localizing a database mean? You can either localize the structure or the data. Localizing the structure (table names...) doesn't make sens because the user is not aware of it. Localizing the data doesn't make sense either, because that means that if the users changes language settings, next time he uses your app he won't see his data!
If the DB only contains static data and you need to provide a different DB for different languages, you could use localization to lookup for the database filename.
Of course, yes, you can.
When you do your queries, just append "en" or "ta".
Something like "SELECT FROM Country_" + yourLocale + "..." - if you want to use two different tables.
OR you could use one single table with an integer field "Language" and you pass an int (0 = english, 1 = tamil - only for alphabetical order, which is easier to remind)...
Something like "... WHERE ... AND Language = 0"
i am new to android development,so dint get me wrong. I am developing an application in which a text is generated.which is normally a word. The word is checked in a database for is corresponding value pair. Here the word is the key and its corresponding value is the value .
Since the text is auto generated it sometimes goes wrong(mis spelled). How do i perform a check of auto generated word to match with the mostly matched letters in the database of key word.
example: auto-generated word(key) - value
americ:
america : a country
Here the auto generatd word is americ(key) is not matched since it only contains america in its pair set.it need to be corrected as america.
You are probably using SQLite. Your best bet is soundex, which is desribed here.
Soundex has many shortcomings, but it might get you started. If you want a real measure, then go with Levenshtein distance, which is not built into the database (as far as I know).
Suppose, A autocompletetextview will provide multiple text data out of which, i want to display particular text only in autocompletetextview by discarding other data.
Example:
Textview options are:
goog - Google Inc
yhoo - Yahoo
msft - Microsoft Corporation
if user select the first one, the autocompletetextview should contain only goog.
I've no idea..how do i begin. Please can u explain me with one example.
I guess you could set this up with a structure as key/value.
goog will be the key, and goog - Google Inc yhoo - Yahoo msft - Microsoft Corporation the value.
In either a database, or a suitable Collection you'd be simply able to find the other, no matter if you provide the key or the value.