Skip to content

Instantly share code, notes, and snippets.

View durranilab's full-sized avatar
🎯
Focusing

Musaddiq Durrani durranilab

🎯
Focusing
View GitHub Profile
@durranilab
durranilab / FileUtils.java
Last active March 6, 2021 13:32 — forked from HBiSoft/FileUtils.java
This fixes the issue when selecting a file from Downloads directory as well as the SD Card. This class can be called like this: String sourcePath = FileUtils.getRealPathFromURI_API19(this, data.getData());
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;