Mona
Mona

Reputation: 6175

get file path for uri.parse() in android

I have the location of a file,

D:\Android\WorkSpace\myApp\res\drawable-hdpi\image.PNG

how can I get the file path to use inside uri.parse()?

Upvotes: 2

Views: 11649

Answers (2)

Mona
Mona

Reputation: 6175

I found it much easier to use "getPackageName()" method. so here is what worked for me,

 Uri path = Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.image));

Upvotes: 6

Android Killer
Android Killer

Reputation: 18489

pass the path to your URI path like as follows.may be in two ways:

1.Uri path=Uri.parse("android.resource://" + PACKAGE_NAME + "/" + R.drawable.image);
2. Uri path=uri.parse("android.resource://"+PACKAGE_NAME+"/"+"drawable/image"

Upvotes: 2

Related Questions