Shade
Shade

Reputation: 1

Android file path of /res folder

In my android project I have got an image (img.png) in my res folder that. Now I need the file path of it.

I have already tried to use the assets folder but it didn't work and I prefer the res folder.

Thank you very much!!!

Upvotes: 0

Views: 437

Answers (2)

abdello
abdello

Reputation: 158

If you try to get it by java programmatically you the simple way is: - Copy past the image into drawable folder - Use getRessources.getDrawable(R.drawable.imageName) in your ACTIVITY. - if you call it from a class you must parse your Activity (this) to the class function within you make the call.

Hope this is useful.

Upvotes: 0

Gabe Sechan
Gabe Sechan

Reputation: 93561

Res files don't have paths. They're resources- you get them by using Resources.getDrawable(). There is no way to access them as files or via the File api.

Assets are also not files. You access them via the AssetManager API.

Upvotes: 1

Related Questions