Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

android - how to update gallery after moving photo programmatically?

I am moving photo from on directory to another using following code

File oldfile= new File(originalImagePath);              
File newfile=new File(newImagePath);
boolean d=oldfile.renameTo(newfilee);
if(d){

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + newfilee.getPath())));
 }

photos moved to new directory successfully but it take too long time when photos are more in count to update gallery and gallery updates after around 30 seconds or more So give me suggestion what I should do if logic to update file using sendBroadcast is wrong?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

to remove from gallery

try {

  getContentResolver().delete();

   } catch (Exception e) {
        e.printStackTrace();
   }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...