Java tutorial
//package com.java2s; import android.content.Context; import android.net.Uri; import android.os.ParcelFileDescriptor; public class Main { public static long getFileSize(Context context, Uri uri) { try { ParcelFileDescriptor fd = context.getContentResolver().openFileDescriptor(uri, "r"); long size = fd.getStatSize(); fd.close(); return size; } catch (Throwable exception) { return 0; } } }