android - How to get multiple ringtones from a ringtone folder in file manager? -


i have attached code single ringtone in file manager. have multiple ringtones ringtone folder in file manager.

public void ringtone(){      log.i("test", "inside ringtone");     string filepath = environment.getexternalstoragedirectory().getabsolutepath();     log.i("filepath", filepath);     filepath = filepath + "/ringtone";     final mediametadataretriever retriever = new mediametadataretriever();     retriever.setdatasource(filepath);     final string title = new file(filepath).getname();     contentvalues values = new contentvalues();     values.put(mediastore.mediacolumns.data, title);     values.put(mediastore.mediacolumns.title, "song");     values.put(mediastore.mediacolumns.size, "450kb");     values.put(mediastore.mediacolumns.mime_type, "audio/mp3");     values.put(mediastore.audio.media.is_ringtone, true);     values.put(mediastore.audio.media.is_notification, false);     values.put(mediastore.audio.media.is_alarm, false);     values.put(mediastore.audio.media.is_music, false);      //insert database     uri uri = mediastore.audio.media.getcontenturiforpath(title);     log.i("uri", "" + uri);     getcontentresolver().delete(uri, mediastore.mediacolumns.data + "=\"" + title + "\"", null);     uri newuri = getapplicationcontext().getcontentresolver().insert(uri, values);     //log.i("uri",""+newuri);     ringtonemanager.setactualdefaultringtoneuri(getapplicationcontext(), ringtonemanager.type_ringtone, newuri); } } 


Comments