Ziv Sion
Ziv Sion

Reputation: 165

Android studio get file path by name

I want to get the full address by the name of the file. For example:

Input young_volcanos - String name

Output R.raw.young_volcanos - int path

Is it possible?

Upvotes: 0

Views: 111

Answers (1)

Vishal Nagvadiya
Vishal Nagvadiya

Reputation: 1278

Use getIdentifier()

int resourceId = this.getResources().getIdentifier("file_name", "raw", this.getPackageName());

Upvotes: 1

Related Questions