Support Android App for Multiple Languages in Application Level - android

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!

Related

How to upload text view from android to a database in a website using a button

I'm currently doing a project from one of my subjects in my university. I'm about to do an attendance app that checks if the professors are present, late, or absent in the room based on the schedule. I made an app in an android studio which uses radio groups and radio buttons that will change the text in the text view which will show if the professors attendance status. I'm thinking of making a button that will upload the text views with the attendance statuses to a website which holds the data(database).
I'm not used to programming in the android studio that is why I would like to know if a way to upload the text views on a website. Thanks
It's quite simple, You have to create Weg api that you can call from the android mobile application and pass the current status of the professor or the whatever you want to pass on the server. That api will update the database as per whatever you have passed from the mobile application.
Also, One more thing that you can not pass the text view, you just need to pass the text of that view.
I hope, you will get answer from this.
Happy coding...
Assign value of textview to a string variable.
And use this string in your api to pass data.
For example if you have a textview with name teacher, you can get its value using this line.
String st_teacher = teacher.getText();
Now use that st_teacher value in your api to upload data.

RealTimeDataBase shows different text depending on language device Android

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.

Checking Language type of data coming from database

I have stored data in SQLite database in both English and Hindi.
I have two columns in database, name and address respectively, and I am storing some raw in English and some in Hindi statically.
Now, My Question is "How can I know about that which type of data I am fetching from database ?"
Is it in English language or Hindi language?
Is there any language checker available in Android?
How can I get done this task ?
Thanks in Advance.
Why don't you create a new column for flag 'language_type'
When value equals
1 :- Hindi
2 :- English
While entering the data, You can check the flag accordingly.

How to represent user application settings in Android

Iam working on an android application and have trouble making a decision for the architecture saving application data.
Following case:
In the app the user has the possibility to create new general objects and give them properties he want. To support this, i want to give them a list with favorites before creating the input form, for example a car. It has color, weight, speed, horsepower etc.
So the user can choose a often picked object (for example the car) and will get the appropriate fields for the form he has to fill (color, weigth ...).
This list should be smart. The more you pick an item, the higher it appears in the list. And this presets have to be editable in preferences.
And thats the point. Should I implement my idea with the preferences framework from android (save it to xml as different preferences types and simply load due preferencebuilder) or should i create own xml objects and save it to self created user file location?
My second question: if i use the preference framework method .... is this made good for dynamically add entries at runtime? the ressources are in the res folder, but what if there are individual user entries? will they also be saved in the program folder or is there a special user data folder where the files (maybe encrypted) are in?
Thank you
Storing such complex data in SharedPreferences is tricky. What I mean is assuming user created 4 objects and each has 8 properties. You would store 4*8 values in sharedprefs and map them too.
What can be done is maintain an array list of objects created by user. Consecutive to that list maintain counter array list and keep swapping both lists internally as per number of times user has clicked the object. example:
List Name List Counter
ObjA 5
ObjB 3
ObjC 1
ObjD 1
Store these two lists in Shared Prefs.
Now, for the object's properties part (2 possibility arises) :
Maintain a mySQL DB and a table for each object's name. You can store values of each column in it IF you need to store every instance created of the object by user. (every time user clicks the object just show him/her the column names of table and store the values entered)
Example :
ObjA Table :
Color speed horsepower rpm
________________________________
red 20mph 100 3000
black 80mph 500 8000
Consecutively, if you don't want to store every instance value, you can make another sharedPrefs with object as key and an Arraylist of properties as value.

SQlite Language based table selection

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"

Categories

Resources