how to update gallery after moving photo programmatically?

前端 未结 2 1432
傲寒
傲寒 2020-12-16 21:26

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

File oldfile= new File(originalImagePath);              
File newfile=new File(newImagePa         


        
相关标签:
2条回答
  • 2020-12-16 22:06
    if (Build.VERSION.SDK_INT < 19)
        mContext.sendBroadcast(new Intent(
                Intent.ACTION_MEDIA_MOUNTED,
                Uri.parse("file://"
                        + Environment.getExternalStorageDirectory())));
    else {
        MediaScannerConnection
                .scanFile(
                        mContext,
                        new String[]{imageFile.toString()},
                        null,
                        new MediaScannerConnection.OnScanCompletedListener() {
                            public void onScanCompleted(
                                    String path, Uri uri) {
                                Log.i("ExternalStorage", "Scanned "
                                        + path + ":");
                                Log.i("ExternalStorage", "-> uri="
                                        + uri);
                            }
                        });
    }
    
    0 讨论(0)
  • 2020-12-16 22:17

    to remove from gallery

    try {
    
      getContentResolver().delete();
    
       } catch (Exception e) {
            e.printStackTrace();
       }
    
    0 讨论(0)
提交回复
热议问题