android - Get content uri of an audio file from its absolute path -


i have gone through lot of stackoverflow questions couldn't find answer this. there answer image files doesn't work in case.

so have absolute path of file using file.getabsolutepath(). need convert contenturi below query works fine.

cursor tempcursor = context.getcontentresolver().query(uri,                     proj, null, null, null); 

it not working. tried uri.parse(contenturi) doesn't give content uri guess. please me, stuck since long time. !!

you not use get.absolute etc. query medfiastore.audio etc , bring _id , _data. _id song id , _data has full path , track

below piece of code use. feed track name

    public string getthistrackid(context context, string trackname) {     contentresolver cr = context.getcontentresolver();     final string _id = mediastore.audio.media._id;     final string path = mediastore.audio.media.data;     final string[] columns = { _id };     final string[] trackname = { "%"+ trackname +"%" };     string = path + " ?";     string strtrack_id  = null;     cursor crs =cr.query(uri, columns, where, trackname, null);     if(crs!= null && crs.movetofirst()){         strtrack_id  = crs.getstring(crs.getcolumnindexorthrow(_id));         crs.close();     }      return strtrack_id; } 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -