Getting an Inputstream for data managed by a ContentProvider

Put your problem here if it does not fit any of the other categories.

Getting an Inputstream for data managed by a ContentProvider

Postby ronald » Tue Jan 29, 2008 4:44 pm


I'm quite new to Android and am puzzled about the design of a particular functionality I need. To simplify things I made a (fictive) simple use case (which is not exactly what I need but easier to explain).

Step 1: Download a ZIP file with audio clips.

Problem 1: How to store this file?
Storing the ZIP file is fairly simple with the File storage functionality.
Alternatively I could store the ZIP file extracted but since you can not make directories in the file storage this will give issues when another ZIP file is downloaded containing a file with the same name as in a previously downloaded ZIP file.
Storing in the database doesn't seem to be easy either as there is no way to store raw data (a byte[]).

=> Store as a ZIP file seems the "best" solution.

Step 2: Display a list of audio files and play them
Displaying the list is no issue using the ZIPFile class. But then it seems the MediaPlayer only accepts a ContentURI to play. No worries yet, I can implement a ContentProvider to resolve a URI. But to provide raw data the ContentResolver is used, reading the _data field of the URI and opening a file with the name specified in the _data field (see ... iders.html - Creating a Content Provider, step 5) so I would still need the file to be accessable directly rather then in the ZIP file.

Isn't there a way for me to resolve a URI and return an InputStream? I doesn't make sense to me to still go via normal file access.

I am aware of using an emulated SD card, but would like to avoid this extra requirement if possible.

Hope this is clear and thanks already,

Once Poster
Once Poster
Posts: 1
Joined: Tue Jan 29, 2008 4:19 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 7 guests