• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    Uri to actual path (real path)
    Last Modify : 19 July, 2011(02:05)
    Uri 에 대한 정보는 db 내에 보관하고 있는 것 같고 필드 정보는 아래와 같다. 이중 자세히 봐야할 항목은 `_data` 이며 이 항목에 actual path가 보관되어 있다. 즉 query를 날려서 해당 정보를 얻어 오면 된다는 것
    D/        ( 6851): _id: 75
    D/        ( 6851): _data: /system/media/audio/notifications/20_Cloud.ogg
    D/        ( 6851): _display_name: 20_Cloud.ogg
    D/        ( 6851): _size: 36264
    D/        ( 6851): mime_type: application/ogg
    D/        ( 6851): date_added: 1306825850
    D/        ( 6851): date_modified: 1290465326
    D/        ( 6851): title: Cloud
    D/        ( 6851): title_key:%¢M¢%¢N%¢N)%¢N|%¢Mⓒ%
    D/        ( 6851): duration: 2350
    D/        ( 6851): artist_id: 1
    D/        ( 6851): composer: <unknown>
    D/        ( 6851): album_id: 3
    D/        ( 6851): track: 0
    D/        ( 6851): year: null
    D/        ( 6851): is_ringtone: 0
    D/        ( 6851): is_music: 0
    D/        ( 6851): is_alarm: 0
    D/        ( 6851): is_notification: 1
    D/        ( 6851): _data_hashcode: -1657585135
    D/        ( 6851): is_sound: 0
    D/        ( 6851): year_name: <unknown>
    D/        ( 6851): genre_name: <unknown>
    D/        ( 6851): title_focused_index: null
    D/        ( 6851): composer_focused_index: null
    D/        ( 6851): is_podcast: 0
    D/        ( 6851): bookmark: null
    D/        ( 6851): podcast: null
    D/        ( 6851): recently_played: 0
    D/        ( 6851): most_played: 0
    D/        ( 6851): recently_added_remove_flag: 0
    D/        ( 6851): bucket_id: -1608219629
    D/        ( 6851): bucket_display_name: notifications
    D/        ( 6851): bucket_display_name_focused_index: null
    D/        ( 6851): artist_id:1: 1
    D/        ( 6851): artist_key:
    D/        ( 6851): artist: <unknown>
    D/        ( 6851): artist_focused_index: null
    D/        ( 6851): album_id:1: 3
    D/        ( 6851): album_key:%¢N%¢N)%¢Nq%¢Ma%¢ME%¢Ma%¢M¢%¢M&#65533;%¢Nq%¢Ma%¢N)%¢N%¢Nc%-1608219629
    D/        ( 6851): album: notifications
    D/        ( 6851): album_focused_index: null
    D/        ( 6851): path: /system/ringtone
    
    public String getActualPathFromURI(Uri uri) {
    	String[] proj = { "_data" };
    	Cursor cr = managedQuery(uri, proj, null, null, null);
    	if (cr.moveToFirst()) {
    		return cr.getString(0);
    	}
    
    	return null;
    }
    
    ps. activity 가 아닌 상황일 경우 context 를 전달 한 상태에서 (이거 없이는 되는건 없으니..) getContentResolver.query 를 이용하면 된다.

    Comment


    입력하3 1503256786



    Locations of visitors to this page