content://media/external/fs_id

本文深入分析了Android音乐应用中使用ContentResolver和Uri.parse方法查询SD卡标识符的实现细节,解释了content://media/external/fs_id这一特定URI的含义及其作用,揭示了其在不同SD卡更换情况下的行为变化。
AI助手已提取文章相关产品:

http://bbs.youkuaiyun.com/topics/370039121



static
 int getCardId(Context context) {
        ContentResolver res = context.getContentResolver();
        Cursor c = res.query(Uri.parse("content://media/external/fs_id"), nullnullnullnull);
        int id = -1;
        if (c != null) {
            c.moveToFirst();
            id = c.getInt(0);
            c.close();
        }
        return id;
    }


以上代码是com.android.music AP中的一部分。我想问下Uri.parse("content://media/external/fs_id")这个东西是是啥玩意?SDcard的序列号?还是别的什么东西?



content://media/external/fs_id

fs_id:唯一文件系统标识号,也就是定死的
个人理解是:此URL返回Sdcard上和fs_id对应的存储路径下所有媒体文件

content://media/external/fs_id此URL决定了ContentResolver 应该与哪一个ContentProvider对话即和此\packages\providers\MediaProvider\src\com\android\providers\media\MediaProvider.java对话




刚才又看了下代码,有这么一句话"// Only restore the saved playlist if the card is still the same one as when the playlist was saved",看来通过这个URI获取到的是标示外部存储设备的ID,当我们更换SD卡时,通过这个获取到的ID会改变。



Content://media/external/fs_id
media:媒体介质
external:外部的
fs_id:文件系统id

从字面意思看,这个应该就是查询你有几个外部磁盘吧,然后获取磁盘的id以供后继使用



您可能感兴趣的与本文相关内容

Line 129417: 11-11 19:43:43.364749 11449 11667 V OCAM_ThumbnailUI: doInBackground, mMediaInfo: MediaInfo{mId=0, mOrientation=0, mDateTaken=1762861422513, mUri=content://************/4643, mData='null', mTitle='null', mPath='/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4', mMimeType='null', mWidth=0, mHeight=0, mType=1, mBitmap=android.graphics.Bitmap@6ccc811, mbIsPending=false} Line 129448: 11-11 19:43:43.376709 11449 11667 D OCAM_Thumbnail: getLastVideoThumbnail, path: /storage/emulated/0/DCIM/Camera/.pending-1763466206-VID20251111194326.mp4, id: 4643 Line 129625: 11-11 19:43:43.425784 5671 5699 I MediaProvider: Open with lower FS for /storage/emulated/0/DCIM/Camera/.pending-1763466206-VID20251111194326.mp4. Uid: 10179 Line 129699: 11-11 19:43:43.459511 11449 11561 I OCAM_ThumbnailUI: UpdateTransactionBitmapRunnable, latestMediaInfo: MediaInfo{mId=4640, mOrientation=90, mDateTaken=1762861089000, mUri=content://************/4640, mData='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mTitle='Oplus_8', mPath='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false}, mbPaused: false, allowPending: false, transaction.uri: null Line 129699: 11-11 19:43:43.459511 11449 11561 I OCAM_ThumbnailUI: UpdateTransactionBitmapRunnable, latestMediaInfo: MediaInfo{mId=4640, mOrientation=90, mDateTaken=1762861089000, mUri=content://************/4640, mData='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mTitle='Oplus_8', mPath='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false}, mbPaused: false, allowPending: false, transaction.uri: null Line 129701: 11-11 19:43:43.459586 11449 11561 D OCAM_ThumbnailUI: loadTransactionBitmap, mimeType: video/mp4 Uri: content://************/4640 path: /storage/emulated/0/DCIM/Camera/VID20251111193804.mp4 date: 1762861089000 Line 129703: 11-11 19:43:43.459671 11449 11561 D OCAM_Thumbnail: getLastTransitionBitmap, cache media info: MediaInfo{mId=4640, mOrientation=90, mDateTaken=1762861089000, mUri=content://************/4640, mData='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mTitle='Oplus_8', mPath='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false},image media info:null, video media info:MediaInfo{mId=4643, mOrientation=0, mDateTaken=1762861406495, mUri=content://************/4643, mData='/storage/emulated/0/DCIM/Camera/.pending-1763466206-VID20251111194326.mp4', mTitle='null', mPath='null', mMimeType='video/mp4', mWidth=-1, mHeight=-1, mType=-1, mBitmap=null, mbIsPending=true} Line 129703: 11-11 19:43:43.459671 11449 11561 D OCAM_Thumbnail: getLastTransitionBitmap, cache media info: MediaInfo{mId=4640, mOrientation=90, mDateTaken=1762861089000, mUri=content://************/4640, mData='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mTitle='Oplus_8', mPath='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false},image media info:null, video media info:MediaInfo{mId=4643, mOrientation=0, mDateTaken=1762861406495, mUri=content://************/4643, mData='/storage/emulated/0/DCIM/Camera/.pending-1763466206-VID20251111194326.mp4', mTitle='null', mPath='null', mMimeType='video/mp4', mWidth=-1, mHeight=-1, mType=-1, mBitmap=null, mbIsPending=true} Line 129703: 11-11 19:43:43.459671 11449 11561 D OCAM_Thumbnail: getLastTransitionBitmap, cache media info: MediaInfo{mId=4640, mOrientation=90, mDateTaken=1762861089000, mUri=content://************/4640, mData='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mTitle='Oplus_8', mPath='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false},image media info:null, video media info:MediaInfo{mId=4643, mOrientation=0, mDateTaken=1762861406495, mUri=content://************/4643, mData='/storage/emulated/0/DCIM/Camera/.pending-1763466206-VID20251111194326.mp4', mTitle='null', mPath='null', mMimeType='video/mp4', mWidth=-1, mHeight=-1, mType=-1, mBitmap=null, mbIsPending=true} Line 129898: 11-11 19:43:43.665111 3544 4939 D metis_v2_FileObserverDataCollector: origi event: 128, path: VID20251111194326.mp4 [Metis|com.oplus.metis|1.5.5-f48228a] Line 129899: 11-11 19:43:43.665140 3544 4939 D metis_v2_FileObserverDataCollector: event: 128, path: VID20251111194326.mp4 Line 129900: 11-11 19:43:43.665261 3544 4939 I metis_v2_FileObserverDataCollector: RecursiveFileObserver.onEvent(): event=128, monitoredPath=/sdcard/DCIM/Camera, relativePath=VID20251111194326.mp4 Line 129913: 11-11 19:43:43.677474 3544 4939 D metis_v2_FileObserverDataCollector: File or subdirectory was created or moved to monitored path:/sdcard/DCIM/Camera/VID20251111194326.mp4 Line 130033: 11-11 19:43:43.763154 11449 14647 V OCAM_CallGalleryPreDecodeThread: callGalleryToPreDecodeVideo, uri: content://************/4643, path: /storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 Line 130035: 11-11 19:43:43.763532 11449 14647 V OCAM_GalleryPreCodeClient: call, image_uri: content://************/4643, image_path: /storage/emulated/0/DCIM/Camera/VID20251111194326.mp4, image_date: 1762861422513 Line 130042: 11-11 19:43:43.769937 11449 11481 I OCAM_ThumbnailUI: mUriObserver, onChange, thumbnailUri: content://************/4643, observerUri: content://************/4643, latestMediaInfo: MediaInfo{mId=4643, mOrientation=90, mDateTaken=1762861422513, mUri=content://************/4643, mData='/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4', mTitle='VID20251111194326', mPath='/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false} Line 130042: 11-11 19:43:43.769937 11449 11481 I OCAM_ThumbnailUI: mUriObserver, onChange, thumbnailUri: content://************/4643, observerUri: content://************/4643, latestMediaInfo: MediaInfo{mId=4643, mOrientation=90, mDateTaken=1762861422513, mUri=content://************/4643, mData='/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4', mTitle='VID20251111194326', mPath='/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false} Line 130042: 11-11 19:43:43.769937 11449 11481 I OCAM_ThumbnailUI: mUriObserver, onChange, thumbnailUri: content://************/4643, observerUri: content://************/4643, latestMediaInfo: MediaInfo{mId=4643, mOrientation=90, mDateTaken=1762861422513, mUri=content://************/4643, mData='/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4', mTitle='VID20251111194326', mPath='/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false} Line 130458: 11-11 19:43:43.910127 12474 14629 D g_db.GalleryProvider: insert table: local_media, values: {duration=1267, sync_status=1, orientation=90, height=1080, bucket_display_name=Ca***a, media_id=4643, volume_name=external_primary, date_modified=0, _display_name=VID20******194326.mp4, datetaken=1762861422513, mime_type=video/mp4, _data=/st***ge/em****ed/*/D**M/Ca***a/VID20******194326.m*4, _size=0, title=VID20******194326, width=1920, generation_modified=1762861423855, is_pending=0, date_added=1762861406, _original_data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4, bucket_id=-1739773001, media_type=3, invalid=0, relative_path=D**M/Ca***a/} Line 130676: 11-11 19:43:44.012485 11449 26045 I OCAM_ThumbnailUI: mUriObserver, onChange, thumbnailUri: content://************/4643, observerUri: content://************/4643, latestMediaInfo: MediaInfo{mId=4640, mOrientation=90, mDateTaken=1762861089000, mUri=content://************/4640, mData='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mTitle='Oplus_8', mPath='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false} Line 130676: 11-11 19:43:44.012485 11449 26045 I OCAM_ThumbnailUI: mUriObserver, onChange, thumbnailUri: content://************/4643, observerUri: content://************/4643, latestMediaInfo: MediaInfo{mId=4640, mOrientation=90, mDateTaken=1762861089000, mUri=content://************/4640, mData='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mTitle='Oplus_8', mPath='/storage/emulated/0/DCIM/Camera/VID20251111193804.mp4', mMimeType='video/mp4', mWidth=1920, mHeight=1080, mType=-1, mBitmap=null, mbIsPending=false} Line 130908: 11-11 19:43:44.066836 5671 5699 W ModernMediaScanner: Failed to visit /storage/emulated/0/DCIM/Camera/VID20251111194326.mp4: java.nio.file.NoSuchFileException: /storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 Line 130908: 11-11 19:43:44.066836 5671 5699 W ModernMediaScanner: Failed to visit /storage/emulated/0/DCIM/Camera/VID20251111194326.mp4: java.nio.file.NoSuchFileException: /storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 Line 131084: 11-11 19:43:44.158462 11449 12489 D MediaScannerConnection: Scanned /storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 to null Line 135273: 11-11 19:43:45.148470 12474 12474 E SQLiteDatabase: Error inserting duration=1267 resolution=1920x1080 sync_status=1 latitude=30.527246666666663 orientation=90 height=1080 bucket_display_name=Camera media_id=4643 volume_name=external_primary _display_name=VID20251111194326.mp4 datetaken=1762861422513 mime_type=video/mp4 _data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 _size=0 title=VID20251111194326 width=1920 longitude=104.09507333333335 gps_key=140185068996 generation_modified=1762861425140 is_pending=0 date_added=1762861425 _original_data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 bucket_id=-1739773001 media_type=3 invalid=4 relative_path=DCIM/Camera/ Line 135273: 11-11 19:43:45.148470 12474 12474 E SQLiteDatabase: Error inserting duration=1267 resolution=1920x1080 sync_status=1 latitude=30.527246666666663 orientation=90 height=1080 bucket_display_name=Camera media_id=4643 volume_name=external_primary _display_name=VID20251111194326.mp4 datetaken=1762861422513 mime_type=video/mp4 _data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 _size=0 title=VID20251111194326 width=1920 longitude=104.09507333333335 gps_key=140185068996 generation_modified=1762861425140 is_pending=0 date_added=1762861425 _original_data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 bucket_id=-1739773001 media_type=3 invalid=4 relative_path=DCIM/Camera/ Line 135273: 11-11 19:43:45.148470 12474 12474 E SQLiteDatabase: Error inserting duration=1267 resolution=1920x1080 sync_status=1 latitude=30.527246666666663 orientation=90 height=1080 bucket_display_name=Camera media_id=4643 volume_name=external_primary _display_name=VID20251111194326.mp4 datetaken=1762861422513 mime_type=video/mp4 _data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 _size=0 title=VID20251111194326 width=1920 longitude=104.09507333333335 gps_key=140185068996 generation_modified=1762861425140 is_pending=0 date_added=1762861425 _original_data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 bucket_id=-1739773001 media_type=3 invalid=4 relative_path=DCIM/Camera/ Line 135273: 11-11 19:43:45.148470 12474 12474 E SQLiteDatabase: Error inserting duration=1267 resolution=1920x1080 sync_status=1 latitude=30.527246666666663 orientation=90 height=1080 bucket_display_name=Camera media_id=4643 volume_name=external_primary _display_name=VID20251111194326.mp4 datetaken=1762861422513 mime_type=video/mp4 _data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 _size=0 title=VID20251111194326 width=1920 longitude=104.09507333333335 gps_key=140185068996 generation_modified=1762861425140 is_pending=0 date_added=1762861425 _original_data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4 bucket_id=-1739773001 media_type=3 invalid=4 relative_path=DCIM/Camera/ Line 135323: 11-11 19:43:45.148825 12474 12474 D g_db.GalleryProvider: insertInternal cost: 8, insert table: local_media, values: {duration=1267, resolution=1920x1080, sync_status=1, latitude=false, orientation=90, height=1080, bucket_display_name=Ca***a, media_id=4643, volume_name=external_primary, _display_name=VID20******194326.mp4, datetaken=1762861422513, mime_type=video/mp4, _data=/st***ge/em****ed/*/D**M/Ca***a/VID20******194326.m*4, _size=0, title=VID20******194326, width=1920, longitude=false, gps_key=140185068996, generation_modified=1762861425140, is_pending=0, date_added=1762861425, _original_data=/storage/emulated/0/DCIM/Camera/VID20251111194326.mp4, bucket_id=-1739773001, media_type=3, invalid=4, relative_path=D**M/Ca***a/}, rowId: -1 Line 138091: 11-11 19:43:46.159004 5671 14386 I MediaProvider: Open with lower FS for /storage/emulated/0/DCIM/Camera/VID20251111193614.mp4. Uid: 10158 Line 138094: 11-11 19:43:46.167428 5671 28837 I MediaProvider: Open with lower FS for /storage/emulated/0/DCIM/Camera/VID20251111193804.mp4. Uid: 10158
11-27
freeswitch@localhost.localdomain> recv 1026 bytes from udp/[183.227.181.232]:1864 at 09:19:10.523919: ------------------------------------------------------------------------ INVITE sip:18996228654@27.25.152.174:5080 SIP/2.0 Via: SIP/2.0/UDP 10.168.1.102:59028;branch=z9hG4bK-d87543-b7678846ac1d547d-1--d87543-;rport Max-Forwards: 70 Contact: <sip:03512332064@183.227.181.232:1864> To: "18996228654"<sip:18996228654@27.25.152.174:5080> From: "03512332064"<sip:03512332064@27.25.152.174:5080>;tag=842b1e78 Call-ID: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. CSeq: 1 INVITE Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO Content-Type: application/sdp User-Agent: eyeBeam release 1011d stamp 40820 Content-Length: 435 v=0 o=- 8 2 IN IP4 10.168.1.102 s=CounterPath eyeBeam 1.5 c=IN IP4 10.168.1.102 t=0 0 m=audio 15344 RTP/AVP 0 8 18 101 a=alt:1 3 : 0E+mq1nU hFt+pKdF 172.28.16.1 15344 a=alt:2 2 : 65/yrvXK tFeCv5wr 172.17.144.1 15344 a=alt:3 1 : dKt7HfUt 78IDBaMu 10.168.1.102 15344 a=fmtp:18 annexb=no a=fmtp:101 0-15 a=rtpmap:18 G729/8000 a=rtpmap:101 telephone-event/8000 a=sendrecv a=x-rtp-session-id:02EC42FF7A2C4B7B91C41D4000CC93D6 2025-07-19 09:19:10.517138 100.00% [NOTICE] switch_channel.c:1142 New Channel sofia/external/03512332064@27.25.152.174:5080 [4bd59857-2eb6-4470-987d-446b63d19f14] 2025-07-19 09:19:10.517138 100.00% [INFO] sofia.c:10460 sofia/external/03512332064@27.25.152.174:5080 receiving invite from 183.227.181.232:1864 version: 1.10.12-release git a88d069 2024-08-02 21:02:27Z 64bit call-id: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. 2025-07-19 09:19:10.517138 100.00% [INFO] mod_dialplan_xml.c:639 Processing 03512332064 <03512332064>->18996228654 in context public send 448 bytes to udp/[183.227.181.232]:1864 at 09:19:10.526257: ------------------------------------------------------------------------ SIP/2.0 100 Trying Via: SIP/2.0/UDP 10.168.1.102:59028;branch=z9hG4bK-d87543-b7678846ac1d547d-1--d87543-;rport=1864;received=183.227.181.232 From: "03512332064"<sip:03512332064@27.25.152.174:5080>;tag=842b1e78 To: "18996228654"<sip:18996228654@27.25.152.174:5080> Call-ID: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. CSeq: 1 INVITE User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Content-Length: 0 EXECUTE [depth=0] sofia/external/03512332064@27.25.152.174:5080 set(outside_call=true) EXECUTE [depth=0] sofia/external/03512332064@27.25.152.174:5080 export(RFC2822_DATE=Sat, 19 Jul 2025 09:19:10 +0800) EXECUTE [depth=0] sofia/external/03512332064@27.25.152.174:5080 log(INFO Calling outbound number: 18996228654) 2025-07-19 09:19:10.517138 100.00% [INFO] mod_dptools.c:1865 Calling outbound number: 18996228654 EXECUTE [depth=0] sofia/external/03512332064@27.25.152.174:5080 bridge(sofia/gateway/121_40_149_63_6086/18996228654) 2025-07-19 09:19:10.517138 100.00% [NOTICE] switch_channel.c:1142 New Channel sofia/external/18996228654 [35bf0415-4fe3-4206-8d41-eda1d8e43604] 2025-07-19 09:19:10.517138 100.00% [INFO] sofia_glue.c:1659 sofia/external/18996228654 sending invite call-id: (null) send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:10.529992: ------------------------------------------------------------------------ INVITE sip:18996228654@121.40.149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:03512332064@27.25.152.174>;tag=pa6eaSDe6Xyej To: <sip:18996228654@121.40.149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149_63_6086@27.25.152.174:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:03512332064@27.25.152.174>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:11.530080: ------------------------------------------------------------------------ INVITE sip:18996228654@121.40.149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:03512332064@27.25.152.174>;tag=pa6eaSDe6Xyej To: <sip:18996228654@121.40.149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149_63_6086@27.25.152.174:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:03512332064@27.25.152.174>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:13.530314: ------------------------------------------------------------------------ INVITE sip:18996228654@121.40.149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:03512332064@27.25.152.174>;tag=pa6eaSDe6Xyej To: <sip:18996228654@121.40.149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149_63_6086@27.25.152.174:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:03512332064@27.25.152.174>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:17.530507: ------------------------------------------------------------------------ INVITE sip:18996228654@121.40.149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:03512332064@27.25.152.174>;tag=pa6eaSDe6Xyej To: <sip:18996228654@121.40.149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149_63_6086@27.25.152.174:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:03512332064@27.25.152.174>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:25.531945: ------------------------------------------------------------------------ INVITE sip:18996228654@121.40.149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:03512332064@27.25.152.174>;tag=pa6eaSDe6Xyej To: <sip:18996228654@121.40.149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149_63_6086@27.25.152.174:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:03512332064@27.25.152.174>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:41.532767: ------------------------------------------------------------------------ INVITE sip:18996228654@121.40.149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:03512332064@27.25.152.174>;tag=pa6eaSDe6Xyej To: <sip:18996228654@121.40.149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149_63_6086@27.25.152.174:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:03512332064@27.25.152.174>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 2025-07-19 09:19:42.517142 100.00% [NOTICE] sofia.c:8736 Hangup sofia/external/18996228654 [CS_CONSUME_MEDIA] [RECOVERY_ON_TIMER_EXPIRE] 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_core_session.c:1762 Session 6 (sofia/external/18996228654) Ended 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_core_session.c:1766 Close Channel sofia/external/18996228654 [CS_DESTROY] 2025-07-19 09:19:42.537141 100.00% [INFO] mod_dptools.c:3635 Originate Failed. Cause: RECOVERY_ON_TIMER_EXPIRE 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_channel.c:5012 Hangup sofia/external/03512332064@27.25.152.174:5080 [CS_EXECUTE] [RECOVERY_ON_TIMER_EXPIRE] send 845 bytes to udp/[183.227.181.232]:1864 at 09:19:42.544835: ------------------------------------------------------------------------ SIP/2.0 408 Request Timeout Via: SIP/2.0/UDP 10.168.1.102:59028;branch=z9hG4bK-d87543-b7678846ac1d547d-1--d87543-;rport=1864;received=183.227.181.232 Max-Forwards: 70 From: "03512332064"<sip:03512332064@27.25.152.174:5080>;tag=842b1e78 To: "18996228654" <sip:18996228654@27.25.152.174:5080>;tag=N1cp8Xva9m8Up Call-ID: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. CSeq: 1 INVITE User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Accept: application/sdp Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Reason: Q.850;cause=102;text="RECOVERY_ON_TIMER_EXPIRE" Content-Length: 0 Remote-Party-ID: "18996228654" <sip:18996228654@27.25.152.174>;party=calling;privacy=off;screen=no 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_core_session.c:1762 Session 5 (sofia/external/03512332064@27.25.152.174:5080) Ended 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_core_session.c:1766 Close Channel sofia/external/03512332064@27.25.152.174:5080 [CS_DESTROY] recv 374 bytes from udp/[183.227.181.232]:1864 at 09:19:42.577655: ------------------------------------------------------------------------ ACK sip:18996228654@27.25.152.174:5080 SIP/2.0 Via: SIP/2.0/UDP 10.168.1.102:59028;branch=z9hG4bK-d87543-b7678846ac1d547d-1--d87543-;rport To: "18996228654" <sip:18996228654@27.25.152.174:5080>;tag=N1cp8Xva9m8Up From: "03512332064"<sip:03512332064@27.25.152.174:5080>;tag=842b1e78 Call-ID: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. CSeq: 1 ACK Content-Length: 0
07-20
<think>我们正在讨论Android中的Uri,特别是`content://media/external/downloads/847`。根据引用内容,我们知道: - Android使用Uri(统一资源标识符)来标识资源,如媒体文件。 - Uri的格式通常为:`content://authority/path/id`。 - 引用[1]提到:`content://media/external`是媒体存储的Uri,例如图片的Uri可能是`content://media/external/images/media/4`。 因此,`content://media/external/downloads/847`可以拆解为: - Scheme: `content` - Authority: `media` - Path: `/external/downloads` - ID: `847` 这个Uri指向的是下载目录(downloads)中ID为847的文件。在Android中,下载的文件通常存储在`Downloads`目录下,并通过`MediaStore`进行管理。 根据引用[2]和[3],我们可以通过Uri获取文件路径,或者通过文件路径获取Uri。但是,这里用户直接询问的是这个Uri的含义。 此外,引用[4]提到了一个异常:`IllegalStateException: Unknown URL: content://media/external/audio/albumart/-1`,这是由于系统无法找到对应的资源。因此,如果`content://media/external/downloads/847`指向的文件不存在或ID无效,也可能导致类似问题。 总结: - `content://media/external/downloads/847`是一个指向下载文件夹中ID为847的文件的Uri。 - 在Android中,可以使用`MediaStore` API来查询和操作此类Uri。 相关问题: 1. 如何通过`content://media/external/downloads/847`获取实际文件路径? 2. 当遇到`IllegalStateException: Unknown URL`异常时,如何解决? 3. 如何通过文件路径获取对应的MediaStore Uri? </think> ### `content://media/external/downloads/847` 解析 #### 1. **URI 结构解析** 此 URI 遵循 Android 内容提供者(Content Provider)的标准格式: ``` content://[authority]/[path]/[id] ``` - **`content://`**:Android 内容协议的固定前缀,表示通过内容提供者访问数据[^1][^2]。 - **`media`**:授权(authority),标识管理该数据的系统组件(此处为媒体存储服务)。 - **`external/downloads`**:路径(path),表示外部存储的下载目录(对应设备上的 `/sdcard/Download`)。 - **`847`**:资源 ID,代表下载目录中第 847 个文件的唯一标识符[^3]。 #### 2. **功能与用途** - **文件定位**:此 URI 指向设备下载目录中的特定文件(如 PDF、图片、压缩包等),ID `847` 由系统自动分配。 - **数据访问**:通过 `ContentResolver` 查询文件信息(如路径、大小、类型): ```java Cursor cursor = getContentResolver().query( Uri.parse("content://media/external/downloads/847"), null, null, null, null ); ``` - **常见场景**: - 应用通过 ID 直接访问下载文件(避免路径依赖)。 - 系统相册/文件管理器显示下载内容[^2][^3]。 #### 3. **转换为实际路径** 引用[^2]提供了从 URI 获取文件路径的方法: ```java String uriString = "content://media/external/downloads/847"; Uri uri = Uri.parse(uriString); String[] projection = {MediaStore.Downloads.DATA}; // 关键:查询_DATA字段 Cursor cursor = getContentResolver().query(uri, projection, null, null, null); if (cursor != null && cursor.moveToFirst()) { int pathIndex = cursor.getColumnIndex(MediaStore.Downloads.DATA); String filePath = cursor.getString(pathIndex); // 例如:/sdcard/Download/file.pdf File file = new File(filePath); } cursor.close(); ``` #### 4. **常见问题与解决** - **`IllegalStateException` 异常**(引用[^4]场景): - **原因**:ID 无效或文件被删除(如 `ID=-1`)。 - **解决方案**: 1. 检查 ID 是否存在:`SELECT _id FROM downloads WHERE _id=847`。 2. 清理无效媒体缓存:执行 `MediaScanner` 扫描存储: ```bash adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard ``` #### 5. **文件路径与 URI 互转** - **路径 → URI**(引用[^3]): ```java File file = new File("/sdcard/Download/file.pdf"); Uri uri = Uri.fromFile(file); // 生成 file:// 格式 URI // 转为 content:// 格式需通过 MediaStore 查询 ``` ### 总结 - `content://media/external/downloads/847` 是 Android 系统通过媒体存储服务访问下载文件的标准化标识。 - 实际文件路径通常存储在 `MediaStore.Downloads.DATA` 字段中。 - 无效 ID 会导致异常,需检查文件是否存在或重建媒体索引。 --- ### 相关问题 1. 如何通过文件路径查询对应的 `content://` URI? 2. 为什么 Android 推荐使用 `content://` URI 而非直接文件路径? 3. 如何处理 `MediaStore` 中已删除文件残留的无效 ID? 4. 如何批量获取下载目录中所有文件的 URI 列表? 5. `content://media/external` 与 `content://media/internal` 有何区别?
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值