spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Best practices for storing translatable android strings in DB


From your comments, I understand that your actual problem is storing a spinner value in the database.

As you're saying in your question, you shouldn't store the string of the spinner but an integer representing that value. And then use your spinner with a List< Integer > instead of a List< String >.

An alternative to that int index with no meaning is an enumeration :

public enum SpinnerValues {
    EXAMPLE_1(R.string.example1_string),
    EXAMPLE_2(R.string.example2_string),
    EXAMPLE_3(R.string.example3_string);

    private int mStringResId;

    private SpinnerValues(int stringResourceId) {
        mStringResId = stringResourceId;
    }

    public int getStringResId() {
        return mStringResId;
    }
}

In that case, your spinner data would be List< SpinnerValue > and you would store your enum in database either with the ordinal or with the string representation of the enum (I would recommand the string value so that changing order of the enum values wouldn't break your database).


Categories : Android

Related to : Best practices for storing translatable android strings in DB
Quickest way of storing and accessing Strings in an array
Whenever your processing 10,000 words you can expect some delays. Depending on what word is set to you might be able to filter a bit better but as far as your code shows that's the best way to do it.

Categories : Java
Best idea for storing groups with users in database in android
This is a standard design: One table with the groups, another with the users. If a user has only one group add is as foreign key in the user table. If a user belongs to multiple groups add a 3rd table with the n:m relation group table to user table.

Categories : Android
Storing Push Notification messages Locally ,in Phonegap Android App
There are two cases (I will consider the app in background / closed case), forground case would be pretty straight (You can use sqlitePlugin in this case): You receive only one notification - then you will be able to click that notification and store payload details using SqllitePlugin once your app will launch and callback is called. You receive multiple notifications - In this case you will on

Categories : Android
Android - Storing a Camera image file path into SQLite db.
Please check if it helps: Write a method which will return all rows from the images table into a cursor. Create a Cursor adapter and bind it to the list view. Use ImageView.setImageURI() to bind image URI with imageView.

Categories : Sqlite
ANDROID: Swapping strings on a single clickable TextView
I think your problem is with your switch statement . what do you mean switch(R.string.fc_front) ? it's like this : switch (2) { case 2 : ... break; case 1 : ... break; } because in R.java file, every resource stores as a number. you have to check your TextView's text not R.string.fc_front . try this : if (textView.getText().equals("string1")) {

Categories : Java
Recently Add
Duplicate zip entry [commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class])
Android Opengl Vertex greater than 1
Not able to upload image from gallery in Android 4.4
Passing JSONObject to another activity via Intent
Fabric maven repo causes slow gradle builds
java.lang.NullPointerException - onModifiedTouchEvent
Black backgrounds are transparent on Lollipop until app is installed a second time
Android RecyclerView Removing Item - 2 Animation Issues
Disable hamburger to back arrow animation on Toolbar
Gradle 14.4 Fails to Build - Gradle DSL method not found 'packageName()'
Android setParameters failed
Android MultiDex - Questions on Inner Workings
Android camera crash, repeating images, native nav buttons messed up
Location Listener Can't Reach Location
onclick checkbox in listview
Multithreaded Server via Arduino
How to handle backstack referencing deleted items
How to make the overflow popup menu avoid obstructing the action bar?
How to disable screen rotation in Android?
why my application use all memory and get OutOfMemoryError: Failed to allocate?
Setting Toolbar using setSupportActionBar() when resuming a Fragment
Unable to get AppCompat ActionBar/Toolbar to become an overlay
'preferenceCategory' style background isn't working in Lollipop
Android, Expandable List View, Remove child from single entry
Button with getBackground().setAlpha on version 5 - lollipop isn't working correctly
Fill listview from array of objects
Move image across screen with variables calculated at runtime
Android Chrome table border issue
Android Unable to load '.so.1' file
cursor is deactivated prior to calling this method
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.