0

please help me.

I need get a string data in my class, when i use a Resources.getSystem().getString(R.string.test), but get a error: Resources$NotFoundException (id=830139056248)

my code:

  // manage DB
  private class DBHelper extends SQLiteOpenHelper{

    public DBHelper(Context context, String name, CursorFactory factory,
        int version) {
      super(context, name, factory, version);
    }

    // Create DB and insert data
    @Override
    public void onCreate(SQLiteDatabase db) {
      db.execSQL(DB_CREATE);

          ContentValues cv = new ContentValues();

        cv.put(COLUMN_EX_NAME, "TITLE NAME");
        cv.put(COLUMN_EX_IMG,  R.drawable.ex_pic3);
        cv.put(COLUMN_EX_TYPE,  0);
        cv.put(COLUMN_EX_DESCRIPTION, Resources.getSystem().getString(R.string.test));


  }

}

4

1 回答 1

0

尝试这个:

private class DBHelper extends SQLiteOpenHelper{

private Context context;

public DBHelper(Context context, String name, CursorFactory factory, int version) {
  super(context, name, factory, version);
  this.context = context;
}

// Create DB and insert data
@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL(DB_CREATE);
    ContentValues cv = new ContentValues();
    cv.put(COLUMN_EX_NAME, "TITLE NAME");
    cv.put(COLUMN_EX_IMG,  R.drawable.ex_pic3);
    cv.put(COLUMN_EX_TYPE,  0);
    cv.put(COLUMN_EX_DESCRIPTION, context.getString(R.string.test));

}

于 2013-03-29T19:14:18.043 回答