That what I used in my code: public static boolean rename(String orig_name, String new_name, String path) { File Operator1 = new File(path, orig_name); File Operator2 = new File(path, new_name); if (Operator1.exists() == false) { return false; } if (Operator2.exists() == true) { return false; } try { boolean r = Operator1.renameTo(Operator2); return r; } catch (Exception e) { return false; } }
On Thu, Jun 17, 2010 at 2:49 PM, focode <programarun...@gmail.com> wrote: > i have to change the name of a jpg file , for that i have written the > following code > > sdcard = Environment.getExternalStorageDirectory(); > from = new File(sdcard,imagePath.substring(8).toString()); > to = new File(sdcard,"/DCIM/RoseVille_"+Info.getText() > +"_"+Amount.getText()+"_"+timeStampFormat.format(n ew Date())+".jpg"); > > if(from.renameTo(to)==true) > { > /// if renamming is successfull; > } > > this code creates a new file with the required name while the file > which i wanted to change is still their on sd card , if i remount the > sd card then the old file gets deleted and the renamed file remains > their. > > so my problem is how to rename the file without remounting the sd card > > thanks and regards > focode > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en