Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

I want to do the following:

I want to make a very simple gallery application. So I'd like to select a path for the images and set it as a resource. I set it in String.xml.

So I have another class, which 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.....
    }
}
like image 355
George Avatar asked Nov 30 '22 18:11

George


1 Answers

Use getString(resID) but you'll need a Context Object though.

It's a Function of Context, so within an Activity you can write this.getString(R.string.image_dir); or you can skip this altogether...

like image 132
st0le Avatar answered Dec 05 '22 04:12

st0le