File URI

Basic URI: 
file://

File location.

The file URI can point to files on the file system. It is not tied to a specific MIME type. The MIME type can be infered in most cases from the extension provided by the file URI.

Note: File paths on the Android file system start with "/", e.g. "/sdcard". The corresponding file URI can be obtained by prepending "file://", i.e. "file:///sdcard". To recover the original file path, remove the leading "file://".

Comments

View Data

Hi peli,
what if i want to display a notepad file or a word file using the HTMLViewer activity. Is it possible to view the word and pdf file in android using some default application like HTMLViewer. Because in g1 if you open an email with word or pdf attachment, it does open that file. I am trying this code and it open the HTMLViewer activity but displays a blank white page.

Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse("file://" + file.getAbsolutePath());
String type = "application/*";
intent.setDataAndType(data, type);
startActivity(intent);

Do you know the answer of this quesiton?

Thanks,
Payal

File viewer

As far as I know there is no PDF or Word document viewer pre-installed on the G1. In case you open them from your Gmail account in the browser, they are actually rendered on the server, and only the corresponding HTML is displayed in the browser. I don't think the HTMLViewer activity can display Word or PDF files without a server back-end.

In your sample code above, in order to launch a specific activity, you probably need to specify the MIME type. I don't know if "application/*" is enough. Then again, probably there is no viewer installed (or available?) yet for the application MIME types you are looking for.

Peli

File Viewer

So you mean there is no way we can view the word files and pdf files?

No easy way

Let's say, there is no quick and easy way that I know of. If you google for it, there are Java PDF converters that could be ported to Android, and probably one can find something similar for Word documents (from the OpenOffice project). Maybe there are online services that can display these documents as HTML format. I'm sure there will be PDF and Word viewers sooner or later for Android, but I don't know of any so far. (If there are some, please let me know).

Applications providing File URI

Titlesort icon Provides intent actions Provides intent URIs Uses action Uses URI Description
Blackmoon File Browser

Blackmoon File Browser is a file manager similar to OI File Manager.
Features:

  • Browse, open, rename, manage, copy, move, delete or even email files found on your phone. Aware of 100+ registered file extensions.
  • Multiple file selection support.
  • Attach files to email.
  • View thumbnails of image files.
  • Create music playlists with the Send Marked feature.
  • Pack/unpack Zip files.
  • Create Jump Points to any file or folder both in the app and on the Home screen.
Convert CSV View data File URI Pick file File URI

Extension that imports and exports OI Notepad notes or OI Shopping lists.

OI File Manager File URI

OpenIntents File Manager

Applications using File URI

Titlesort icon Provides intent actions Provides intent URIs Uses action Uses URI Description
Blackmoon AttachSave Pick directory

Small app that will save email attachments to the SD card when the attachment is previewed/opened from the built-in Gmail or Email app.

Blackmoon File Browser

Blackmoon File Browser is a file manager similar to OI File Manager.
Features:

  • Browse, open, rename, manage, copy, move, delete or even email files found on your phone. Aware of 100+ registered file extensions.
  • Multiple file selection support.
  • Attach files to email.
  • View thumbnails of image files.
  • Create music playlists with the Send Marked feature.
  • Pack/unpack Zip files.
  • Create Jump Points to any file or folder both in the app and on the Home screen.
Convert CSV View data File URI Pick file File URI

Extension that imports and exports OI Notepad notes or OI Shopping lists.

OI File Manager File URI

OpenIntents File Manager