ファイル名をres/valuesから文字列として参照することにより、アセットにあるxmlファイルを解析することは可能ですか?
Document doc = db.parse(assetManager.open("questions.xml"));
そして、questions.xmlの代わりに@ string / questions.xmlのようなものですか?これを機能させるのに苦労しています。
ファイル名をres/valuesから文字列として参照することにより、アセットにあるxmlファイルを解析することは可能ですか?
Document doc = db.parse(assetManager.open("questions.xml"));
そして、questions.xmlの代わりに@ string / questions.xmlのようなものですか?これを機能させるのに苦労しています。
あなたはこのコードでそれを行うことができます:
Resources res = getApplicationContext().getResources();
String filename = res.getString(R.string.questions);
Document doc = db.parse(assetManager.open(filename));
または1つの簡単な行で:
Document doc = db.parse(assetManager.open(getApplicationContext().getResources().getString(R.string.questions));
お役に立てば幸いです。