Android - get a resource (string) from its unique integer

I want to do the following:

I want to make a very simple gallery app. Therefore, I would like to choose a path for the images and set it as a resource. I set it to String.xml.

So, I have another class that needs the selected path to load all the images from it.

class ImageHolder { public ImageHolder() { this(R.string.image_dir); //problem is here - R.string.image_dir returns a unique int, while what I really need is the string. How can I get it... } public ImageHolder(String path) { .........standart procedure..... } } 
+4
source share
1 answer

Use getString(resID) , but you will need a Context Object.

This is a Context function, so inside the Activity you can write this.getString(R.string.image_dir); or you can skip this at all ...

+21
source

All Articles