0

I'm preparing database definition class for my application. Let me abbreviate it a little:

public class DatabaseDefinition {

     public static class Table {

         public static final String TABLE_NAME = "MyTable";

         public static final int ID_FIELD = "ID";
         public static final String DATA_FIELD = "Data";

         public static final String CREATE_SQL = "CREATE TABLE " + TABLE_NAME + "(" +
             ID_FIELD + " INTEGER PRIMARY KEY," +
             DATA_FIELD + " TEXT)";

         public static String getCreateSql() {

             return CREATE_SQL;
         }
     }
}

I'd like to add some data to this table when the database is being created (very few, like max. 10 entries). The problem is, that this data must be localized. I may store appropriate entries in resources, but I'm not aware of any way of accessing resources without context and I have none in onCreate event of my DatabaseHelper:

@Override
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {

    database.execSQL(DatabaseDefinition.GetCreateSql());
}

How can I access resources from here? Or how else should I solve this problem?

Spook
  • 25,318
  • 18
  • 90
  • 167

1 Answers1

1

Use Context.getApplicationContext() or implement own class extending Application, as described here: Using Application context everywhere?

Community
  • 1
  • 1
tomash
  • 12,742
  • 15
  • 64
  • 81