public class BobDatabase extends SQLiteOpenHelper{
private static final String DATABASE_NAME = "bob.db";
private static final int DATABASE_VERSION = 1;
public static final String DEFAULT_PROFILE = "default_profile";
public BobDatabase(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase database)
{
createProfileTable(database);
createTimeTable(database);
createEventTable(database);
createLocationTable(database);
}
/**
* Creates a table for Profile objects, executes the string create_profile_table_sql
* contained within strings.xml
* @param database
*/
public void createProfileTable(SQLiteDatabase database)
{
database.execSQL(Resources.getSystem().getString(R.string.create_profile_table_sql));
}}
このエラーが発生します
01-14 12:20:57.591:E / AndroidRuntime(1825):原因:android.content.res.Resources $ NotFoundException:文字列リソースID#0x7f040003
エラーの原因となるコードは、createProfileTable内の1行です。具体的には、クラス変数を使用してContextを保持し、context.getString(R.string.create_profile_table_sql)を実行する場合、 Resources.getSystem()。getString(R.string.create_profile_table_sql)です。エラーは発生しませんが、メモリリークを回避したいので、エラーは発生しません。これは、動作するはずです。何が起こっているのか分かりますか?