Reputation: 111
I know this code will open dummytext.txt file on res/raw
InputStream inputStream = getResources().openRawResource(
R.raw.dummytext);
But if filename dummytext
is getting from search query like using this code-
int Index = cursor.getColumnIndexOrThrow(DictionaryDatabase.KEY_DETAILS);
details.setText(cursor.getString(Index));
Then how could i open dummytext file via InputStream inputStream command?
Upvotes: 0
Views: 125
Reputation: 2863
You can get the ResourceId by:
int dummyTextID = this.getResources().
getIdentifier(cursor.getString(Index), "raw", getPackageName());
And then do:
InputStream inputStream = getResources().openRawResource(dummyTextID);
Upvotes: 1