When the user opens the app for the first time I'd like to insert into database some values.
Question 1: How is the best way to insert into database for the first time?
By now I'm using GreenDAO. Should I still continue using it or change it?
I also want to insert the values according to device's language. If the user uses english language so english values must be inserted. If user uses portuguese language so portuguese values must be inserted. And there we go. But if user change language on android settings I also want to update this values.
Question 2: How to update the database after change the device's language?
These values may be deleted by the user, so I want to update only the values that still are inserted.
My initial Class to be inserted:
public class CategoryList {
private final String mLanguage;
public CategoryList(String language) {
mLanguage = language;
}
public List<Category> get() {
final List<Category> list = new ArrayList<>();
switch (mLanguage) {
case "pt":
list.add(new Category(1L, "Passeio", -13388315));
list.add(new Category(2L, "Comida", -48060));
break;
default: // en
list.add(new Category(1L, "Walk", -13388315));
list.add(new Category(2L, "Food", -48060));
break;
}
return list;
}
}
I don't see how I'm going to update only the values that still are inserted.
Question 3: How to update only the values that still are inserted?
Any idea? Thanks.
Edit: I'm going to have hundreds of values (in my case Category type). As you can see in code above the Category has more columns than just 'name' only.
I'd like to insert the correct category according to device's language at first start.
I'd like to update these categories if the user changes the device's language on system.
I don't see how to use res
, because of this I tried using this above class.
How to do this?