android java.io.File.fixSlashes(File.java:185) -
i got error in console crashes & anrs. error showing , couldn't find problem is.
java.lang.nullpointerexception @ java.io.file.fixslashes(file.java:185) @ java.io.file.<init>(file.java:134)
the function code save picture is:
public static string sharephoto(context context, bitmap bmp) { file folder = new file(environment.getexternalstoragedirectory().getabsolutepath() + "/pictures/folder"); boolean success = true; string file_path = null; if (!folder.exists()) { success = folder.mkdir(); } if (success) { file_path = folder + "/img_" + system.currenttimemillis() / 1000 + ".jpg"; } outputstream os = null; try { os = new fileoutputstream(file_path); bmp.compress(bitmap.compressformat.jpeg, 100, os); } catch (ioexception e) { e.printstacktrace(); } } else { // else on failure } intent mediascanintent = new intent(intent.action_media_scanner_scan_file); file f = new file(file_path); uri contenturi = uri.fromfile(f); mediascanintent.setdata(contenturi); context.sendbroadcast(mediascanintent); return file_path; }
try this:
file folder = new file(environment.getexternalstoragedirectory().getabsolutepath() + "/pictures/myfolder");
thing getexternalstoragedirectory()
returns file
. need absolute path of file , concatenate "/pictures/myfolder"
.
Comments
Post a Comment