Get file path from asset

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


Sponsored Links
 Hi,

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");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

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?

Ne0

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
meant.

...
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.

Ne0

--



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. Returning a value from TabActivity.

Hello,

How can I return a value from TabActivity? It seems that the return
value from tab pages vanishes and the caller always receives
RESULT_CANCELED instead of RESULT_OK.

Here is a simple but complete example.
http://www.futuredesktop.org/tmp/TabTest.zip
Please take some time to study and test it.
-----------------------
The main activity is Test.java. It starts the TabPage activity with

The TabPage activity has 2 tab pages with TabContent1 and TabContent2
activities. The main Test.java [by function  onActivityResult(...) ]
should receive individual return values from these tab pages, but this
fails. Why? The return values is always RESULT_CANCELED.

TIA,
  Osmo (Moma) Antero from Norway/Grnland,
  http://www.futuredesktop.org/developing_android_apps_on_ubuntu.html

--~--~---------~--~----~------------~-------~--~----~

2. time of outgoing SMS

Hello,

I am fetching Sent SMS from application. But i am not able to get the
time on which that SMS sent.  I am getting the following things. Can
some one tell me how can i uniquely identify each SMS by the following
field ? My purpose with the time is to uniquely identify sent sms but
is there any alternate for it ?

E/column name0:(  481): _idColumn value :6
E/column name1:(  481): thread_idColumn value :5
E/column name2:(  481): addressColumn value :9377929426
E/column name3:(  481): personColumn value :null
E/column name4:(  481): dateColumn value :1252730723111
E/column name5:(  481): protocolColumn value :null
E/column name6:(  481): readColumn value :1
E/column name7:(  481): statusColumn value :0
E/column name8:(  481): typeColumn value :2
E/column name9:(  481): reply_path_presentColumn value :null
E/column name10:(  481): subjectColumn value :null
E/column name11:(  481): bodyColumn value :Test
E/column name12:(  481): service_centerColumn value :null
--~--~---------~--~----~------------~-------~--~----~

3. Icon and text on button

4. Question about drawing caches in the new SDK

5. Get the phone credentials to use Google Calendar API

6. Can't create a MapView Object -> VerifyError

7. Conference call