Get file path from asset

by Ne0 » Thu, 15 Apr 2010 22:53:27 GMT

Sponsored Links

My app has a pdf user guide in the assets section i want to be able to
launch it with:

Uri path = Uri.fromFile(new File("assets/UserGuide.pdg");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");

It launches QuickOffice to open the pdf as it should, but the file
path is incorrect, how can i get the path of my file in my app?


P.S I am aware not all Android devices have quick office, though this
app will only be install on ones that do. ;-)


Get file path from asset

by Maps.Huge.Info (Maps API Guru) » Thu, 15 Apr 2010 22:58:55 GMT

 Have you tried "file:///android_asset/UserGuide.pdg"?

-John Coryat

"Radar Now!"

"What Zip Code?"


Sponsored Links

Get file path from asset

by Ne0 » Thu, 15 Apr 2010 23:17:34 GMT

 Thanks, I hadn't, but i have now and it did not work. pdg was a typo i

Uri path = Uri.fromFile(new File("assets/UserGuide.pdf");

Any other suggestions?


Get file path from asset

by Michael MacDonald » Fri, 16 Apr 2010 20:52:17 GMT


I don't think other apps can access assets that are part of your .apk
directly--you might have to copy it to the sdcard and have the PDF
viewer access it from there


Get file path from asset

by Ne0 » Fri, 16 Apr 2010 21:11:41 GMT

 Good point, but i still need to know the path to my assets to be able
to copy it don't i? I don't really want to open a Reader and copy it
that way. As a workaround i am now just downloading the file from the
web, but i would much prefer to have it embedded in my package.



Get file path from asset

by umbalaconmeogia » Sat, 08 May 2010 12:21:36 GMT

 To copy a file from assets, you can use
InputStream is = context.getAssets().open("UserGuide.pdf");
to get its content then write it into another file.


Other Threads

1. How to programmically add a new contact in android

That line is after my first insert.


2. Google market policy spells doom for future app publishers?

I wrote about this here:

But it kinda strayed off course, with people suggesting advertising as
a good way to make money.  It may well work, but I think many
developers might want to get paid for their apps instead of relying on
ad revenue.

I read this in the Android Market Business and Program Policies:

2. Android Market Business Policies

Returns: You have 24 hours from the time of purchase (not download) to
return any applications purchased from Android Market for a full
refund of any applicable fees. The option to return an application
within this timeframe will be made available to you through the
Android Market user interface. You may not return any Products other
than applications.

Upgrades: Android Market does not provide upgrade functionality for
any Products. If a Product offers free or paid upgrades, those
upgrades must be obtained directly from the Developer responsible for
the Product.

Reinstalls: You are allowed an unlimited number of reinstalls of each
application obtained via the Market.

So basically, anyone can download an app, then return it within 24
hours for a refund.

I could see a 2-4 hour turn-around, but not 24 hours. A user should
know if an app is bad in the first 15 to 30 minutes of using it.  I
know it only takes me about 30 seconds.    :)

As mentioned in the other thread, this could have serious
repercussions for games.  Imagine a game, like an RPG, that has about
4-8 hours of game play for $2.99 (example).  A user could play it,
beat it, then return it.

This isn't just games, but other fun apps as well.  What about someone
buying it, showing it off to people, then returning it.  Then they
turn around at a later date and do it all over again when they want to
show someone else!  It's like renting for free!

I'm considering an alternative solution.  However, I don't know if it
will violate Google policy.

I am thinking of limiting functionality until after 24 hours has
passed since the time of purchase, checking the time via a web
server.  This way, a user has to wait to be able to complete the game
or use all the features of the app.

I think of it this way.  If I go to the movies and spend $7-10, I get
around 2 hours of entertainment.  If someone plays a game for 2-4
hours, for only a couple buck, shouldn't the same fee apply?

Any thoughts?


3. is the CPU pegged?

4. how to add 3-4 items in list view

5. Bluetooth In Emulator - please help

6. How to programmically add a new contact in android

7. Touch Screen issue with I.MX31