ContentResolver - how to get get random access / seekable representation of the resource which maps to file

How do I access ContentResolver content as a file? There's a simple way to open underlying file-based content as an InputStream, but it's not possible to seek on InputStream. There's RandomAccessFile, but either File or file name is needed to create instances.

Content I'm trying to read is mapped to file (email attachment).


Asked by: Paul557 | Posted: 20-01-2022






Similar questions

Android: SQLite transactions when using ContentResolver

The goal: refresh database from XML data The process: Start transaction Delete all existing rows from the tables Per each main element of parsed XML insert row into main table and get PK Per each child of the main element insert record into 2nd table providing FK from the previous step Commi...


java - Update doesn't work when using ContentResolver to update Contact Groups

I have this code for update: public Boolean update() { try { data.put(ContactsContract.Groups.SHOULD_SYNC, true); ContentResolver cr = ctx.getContentResolver(); Uri uri = ContentUris.withAppendedId(ContactsContract.Groups.CONTENT_URI, Long.parseLong(getId())); int mid = cr.update(uri, data,_ID+"="+getId(), null); // notify registered observers that a row was updated ctx.getContentResol...


android - Am I able to run SQL functions on a ContentResolver columns query?

I am wondering if Android's ContentResolver supports using SQL functions over the columns when you query a ContentProvider. Such as SQLite3 date functions, to get a specific date format, or datediff? What do you know about this?


android - How can I update the album art path using contentResolver?

I want to update/insert a new image for an album in MediaStore but i can't get it work.. This is my code: public void updateAlbumImage(String path, int albumID) { ContentValues values = new ContentValues(); values.put(MediaStore.Audio.Albums.ALBUM_ART, path); int n = contentResolver.update(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, values, MediaStore.Audio.Albums.ALBUM_ID + "=" + albumID,...


android - How to join a ContentResolver Cursor with a Database Cursor?

I get records from the system by quering a ContentResolver. I maintain the order of the items in the database. So I want to display the items in the order taken from my database. How do I merge these two informations? EDIT 1 I am looking after an alternative way now. As what I ideally want is: get order of contacts by a custom order held in my database (this involve...


android - Adding mp3 to the ContentResolver

I know that after downloading an mp3 from your app you need to add it to the ContentResolver to see it on the music player. I am doing it with the following code: private void addFileToContentProvider() { ContentValues values = new ContentValues(7); values.put(Media.DISPLAY_NAME, "display_name"); values.put(Media.ARTIST, "artist"); values.put(Media.ALBUM, "a...


Writing binary data in a sqlite database Android's ContentResolver

I'm reading some sources for Android, and I read this: OutputStream thumbOut = mCr.openOutputStream(uri); bitmap.compress(Bitmap.CompressFormat.JPEG, 85, thumbOut); thumbOut.close(); when trying to store a bitmap (bitmap) in a database (uri is the URI of a row in the database). As far as I can understand, openOutputStream allows to store binary data in the database, but only the path of th...


android - How does a ContentResolver locate the corresponding ContentProvider?

This is a deep magic question. I understand that a call to a ContentResolver method takes a URI specific to the ContentProvider, but how does android actually make the association? I am guessing that any URI matching the authority provided with the ContentProvider in the AndroidManifest.xml is involved. Is the request sent to every provider containing that authority? If I try to create providers whose authority pre...


android - Can I gain access to telephony settings through the contentresolver or elsewhere outside an activity

As part of a test utility on android I am gaining access to the telephony setting in my activity as follows: Cursor cursor = getContentResolver().(Uri.parse("content://telephony/carriers"), null, null, null, null); Is it possible to access the settings outside an activity through the content resolver or through another manner.


android - How long can I hold onto a ContentResolver in an AsyncTask?

I'm trying to write an Activity that spawns off an AsyncTask for a long-running operation, and periodically publishes status updates back to the Activity. I'd like to make sure the AsyncTask survives screen rotation or other destruction conditions like OOM correctly. I've read this thread on the android-...






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top