File::syncMetaData' method request

I wish to request the following, or whatever it should be called, method added to `File’ to fix lameness in Android.

For some daft reason, whenever you plug in a USB connection, it uses an MTP style file presentation which requires new files (and changes sometimes) to be “exported” to the MTP ContentProvider interface, or else they dont appear.

yes, it’s bollox, but unless you do something like this your files can’t be seen.

– hugh.

dummy versions in all implementations except


void File::syncMetaData() const { String pn = getFullPathName(); const LocalRef<jstring> t (javaString (pn)); android.activity.callVoidMethod (JuceAppActivity.scanFile, t.get()); }




private final class SingleMediaScanner implements MediaScannerConnectionClient
private MediaScannerConnection mMs;
private String mFile;

    public SingleMediaScanner(Context context, String filename) 
        mFile = filename;
        mMs = new MediaScannerConnection(context, this);
    public void onMediaScannerConnected() 
        mMs.scanFile(mFile, null);

    public void onScanCompleted(String path, Uri uri) 

public final void scanFile(String filename)
    SingleMediaScanner s = new SingleMediaScanner(this, filename);


Ta! I’ve checked something in now if you want to sanity-check it!

Unfortunately, i’ve found my original hack doesnt work completely after all.

it seems that refreshing the MTP database like this is good for signalling the creation of new files. otherwise they dont appear at all from an external view over USB - so in this repects, it’s a step in the right direction.

However, it still doesnt update the size of the file.

Really annoyingly i have a calendar app that simply appends to a file whenever a new appointment is made. whenever i make such an edit on the mobile, it is NOT reflected in the file when i copy it to the PC. it’s like the edit was never made. This is because the size metadata is not refreshed in the MTP database (along with, probably, everything else).

something not working as obvious as ensuring the USB view of an existing file is the actual file and not some earlier version of it is starting to annoy me a lot because i keep trying to fix this and it doesnt work.