title: Creating example values in SQLite database using strings from strings.xml
body: <p>I got this class, which creates database at the 1st run of the app. I wanted to fill one table with some example values from strings.xml. Basically I'd do this like:</p>
  
  <pre><code>private static final String CATEGORIES_FILL = "INSERT INTO categories VALUES ('', " + getString(R.string.fuel) + "); " +
                                                "INSERT INTO categories VALUES ('', " + getString(R.string.food) + "); " +
                                                "INSERT INTO categories VALUES ('', " + getString(R.string.treatment) + "); " +
                                                "INSERT INTO categories VALUES ('', " + getString(R.string.salary) + "); ";
  </code></pre>
  
  <p>The problem is, the class is not an activity, and string must be static so I can use</p>
  
  <pre><code>db.execSQL(CATEGORIES_FILL);
  </code></pre>
  
  <p>Please correct my approach so I could use strings.xml to do that.</p>
  
  <p>I assume I could do that in my activity class surrounding it with try block, but I don't like the idea of executing this every time I open the activity.</p>
  
  <p><strong>Fragment of database class</strong></p>
  
  <pre><code>private static class DatabaseHelper extends SQLiteOpenHelper {
  
  
      DatabaseHelper(Context context) {
          super(context, DATABASE_NAME, null, DATABASE_VERSION);
  
  
          final String CATEGORIES_FILL = "INSERT INTO categories VALUES ('', " + context.getString(R.string.fuel) + "); " +
          "INSERT INTO categories VALUES ('', " + context.getString(R.string.food) + "); " +
          "INSERT INTO categories VALUES ('', " + context.getString(R.string.treatment) + "); " +
          "INSERT INTO categories VALUES ('', " + context.getString(R.string.salary) + "); "; 
      }
  
      /* Tworzenie tabel
       * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase)
       */
      @Override
      public void onCreate(SQLiteDatabase db) {
          db.execSQL(DATABASE_CREATE);
          db.execSQL(CATEGORIES_FILL); //need the way to access this final here
          db.execSQL(EXPENSES_CREATE);
          db.execSQL(INCOMES_CREATE);
          db.execSQL(BUGS_CREATE);            
      }
  </code></pre>