How can i specify the resource to get from R.res.drawable dynamically?

If you want to get any resource Path then there are two ways :

  1. Using Resource Name

    Syntax : android.resource://[package]/[res type]/[res name]

    Example : If icon.png image file is available in res/drawable folder you can get path like :

    String PATH="android.resource://com.my.package/drawable/icon";

  2. Using Resource Id

    Syntax : android.resource://[package]/[resource_id]

    Example : If icon.png image file is available in res/drawable folder you can get path:

    String PATH="android.resource://com.my.package/" + R.drawable.icon;

This were the examples to get the URI of any image file stored in drawable folder.

Similarly you can get URIs of res/raw folder also.

你可能感兴趣的:(How can i specify the resource to get from R.res.drawable dynamically?)