java - Trying to rename a folder in extSdCard in my android device using code -
i trying develop , application 2 buttons (show,hide) when click show rename folder .pics pics
and hide button rename pics .pics , run media scanner on every click.
here code dont know error, made alot of searches in here non solved problem
button btnshow = (button) findviewbyid(r.id.btnshow); //rename folder vids string sdcard = new string("/storage/sdcard1/"); file = new file(sdcard, (".pics")); file = new file(sdcard, ("pics")); from.renameto(to); //create on click trigger media scan btnshow.setonclicklistener(new onclicklistener() { @override public void onclick(view view) { //broadcast media scanner intent trigger sendbroadcast(new intent(intent.action_media_mounted, uri.parse("file://" + environment.getexternalstoragedirectory()))); //send message toast toast = toast.maketext(getapplicationcontext(), "media scanner triggered....", toast.length_short); toast.show(); } });
i specified path of extsdcard before using environment show normal sdcard , not external sd.
when run on phone media scanner triggered, , folder not renamed.
thanks
you need following permission make changes on sd card
<uses-permission android:name="android.permission.write_external_storage" />
Comments
Post a Comment