Code example for MediaScannerConnection

Methods: scanFile

0
    /** 
     * Send error message to JavaScript. 
     * 
     * @param err 
     */ 
    public void failPicture(String err) {
        this.callbackContext.error(err);
    } 
 
    private void scanForGallery(Uri newImage) {
        this.scanMe = newImage;
        if(this.conn != null) {
            this.conn.disconnect();
        } 
        this.conn = new MediaScannerConnection(this.cordova.getActivity().getApplicationContext(), this);
        conn.connect();
    } 
 
    public void onMediaScannerConnected() { 
        try{ 
            this.conn.scanFile(this.scanMe.toString(), "image/*");