how to get path of file in raw folder android

I need the String Address of the raw folder directory this is my code but it ends with crash

private String zipPath = String.valueOf(getResources().openRawResource(R.raw.zipfile));

Upvotes: 0

Views: 331

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007554

Resources are files on your development machine. They are not files on the device. There is no path to your raw resource.

getResources().openRawResource(R.raw.zipfile) is fine, to give you an InputStream. Use that to read in your resource contents.

And, in general, calling String.valueOf() or toString() on objects is for getting some developer-readable string. The string representation of an InputStream is not going to be a filesystem path.

Upvotes: 2

Related Questions