How to find resource id of a file located in /res/raw folder by its filename?

前端 未结 1 1767
忘了有多久
忘了有多久 2020-12-22 05:16

I want to get the resource id of the file located in /res/raw folder by filename. I have tried the following 2 methods but both of them return resource id as

相关标签:
1条回答
  • 2020-12-22 05:49

    Drop the extension:

    String filename = "abc";
    int id = getResources().getIdentifier(filename, "raw", getPackageName());
    
    0 讨论(0)
提交回复
热议问题