mercredi 19 août 2015

Initialise Data in SQLite from string resource

i'm trying to initalise my sqlite database with some data (here: categories). I learned, that the right place to do this, is the onCreate method of my DatabaseHandler.

Unfortunately i'm not able to get the String resources out of my strings.xml there. I guess the SQLiteOpenDataHelper doesn't contain any resource methods:

   values.put(PAINKILLER_CAT_NAME, R.string.cat2);
   db.insert(TABLE_PAINKILLER_CAT, null, values);

This only stores the ressourceid (like 2139123012) as a String.

getString();

and

getResources().getString();

are no valid methods within my DataBaseHandler.

Is there only a workaround (like setting up the categories from my firststart-activity) or can i use the String-Ressources within my DataBaseHandler?

Aucun commentaire:

Enregistrer un commentaire