android - notify image moved to another folder -


i beginner android programmer. create project hiding image. but, have problem in project. that: use method move photo folder a folder .b(here how hid image gallery) . sure picture in folder a deleted , moved folder .b. however, when open image gallery application still see picture displayed @ folder a.

this method copy picture folder .b:

    public static string copyfile(string path) {         //to do: create folder .b          file pathfrom = new file(path);         file pathto = new file(environment.getexternalstoragedirectory() + "/.b");         file file = new file(pathto, filetoname);          while (file.exists()) {             filetoname = string.valueof(system.currenttimemillis());             file = new file(pathto, filetoname);         }          inputstream in = null;         outputstream out = null;         try {             in = new fileinputstream(pathfrom);             out = new fileoutputstream(file);              byte[] data = new byte[in.available()];             in.read(data);             out.write(data);             in.close();             out.close();              return file.getpath();         } catch (filenotfoundexception e) {             log.e(tag, e.getmessage());             return "error:" + e.getmessage();         } catch (exception e) {             log.e(tag, e.getmessage());             return "error:" + e.getmessage();         }     } 

after copy picture folder .b, delete picture in folder a:

new file(path).delete(); 

so there suggestion notify image gallery know picture moved folder or uri?

**update: suggestion me work fine is: before 4.4,you can call this:

sendbroadcast(new intent(intent.action_media_mounted,uri.parse("file://"+environment.getexternalstoragedirectory()))); after 4.4,try this:

sendbroadcast(new intent(intent.action_media_scanner_scan_file, uri.parse("file://" + file))); 

//the file new image's path

thank firesun , everyonce

after change imgae path,you should notify gallery update,so should send broadcast make it.
before 4.4,you can call this:

sendbroadcast(new intent(intent.action_media_mounted,uri.parse("file://"+environment.getexternalstoragedirectory())));   

after 4.4,try this:

sendbroadcast(new intent(intent.action_media_scanner_scan_file, uri.parse("file://" + file))); //the file new image's path 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -