Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get raw resource file name by id?

Tags:

java

android

I have .ogg files in res/raw, I have implemented a feature to save file to sdcard, and I want to set file name from original file.

like image 965
Funtime Avatar asked Jan 05 '12 20:01

Funtime


3 Answers

It should work with resources.getResourceName( );

like image 167
Snicolas Avatar answered Oct 18 '22 23:10

Snicolas


Use Resources.getResourceName(id) to get package:type/entryname, or Resources.getResourceEntryName(id) to get entry name (file name.)

like image 10
Peter Knego Avatar answered Oct 18 '22 23:10

Peter Knego


If you're looking for the name from a resource ID, you can use Resources.getResourceName(). You can get the Resources object using Context.getResources().

Personally, I'd rather store an array of strings in your strings.xml and map that to the resource IDs, but it depends on what you're really trying to accomplish.

like image 2
EboMike Avatar answered Oct 19 '22 00:10

EboMike