Thursday, 15 January 2015

java - weird behaviour of setting new File Name in android -



java - weird behaviour of setting new File Name in android -

i need create new file in andorid java. :

public static file getabosolutefile(string relativepath, context context) { if (environment.media_mounted.equals(environment.getexternalstoragestate())) { homecoming new file(context.getexternalfilesdir(null), "ae " +".jpg"); } else { toast.maketext(context, "internal", toast.length_short).show(); homecoming new file(context.getfilesdir(), "ae" +".jpg"); } }

but when set - works properly, when alter name , illustration using string method :

public static string getcurrentdate() { string returndate = null; calendar currentdate = calendar.getinstance(); int min = currentdate.get(calendar.minute); string editedminute; if (minute<10) editedminute = "0" + integer.tostring(minute); else editedminute = integer.tostring(minute); returndate= (integer.tostring((currentdate.get(calendar.month) + 1)) + "/" +integer.tostring(currentdate.get(calendar.day_of_month)) + "/" +integer.tostring(currentdate.get(calendar.year)) + " " + integer.tostring(currentdate.get(calendar.hour_of_day)) + ":" + editedminute); homecoming returndate; }

so , when utilize return new file(context.getexternalfilesdir(null), "12/12/12 " +".jpg"); file doesn't create too. tried utilize screening in name - thought reason in this, same result. java's new file(file dir, string name) depending name format? or reason ?

you can't utilize / in file name. used file separator.

for eg.if have folder named app in sd card , in sub folder called sub path mnt/sdcard/app/sub(mnt/sdcard illustration not fixed)

so can see why can't utilize / in file name.

try using _ in place of /.

java android file

No comments:

Post a Comment