Skip to content

Instantly share code, notes, and snippets.

View Anant00's full-sized avatar
🏠
Working from home

Anant Pundir Anant00

🏠
Working from home
View GitHub Profile
@Anant00
Anant00 / FileUtils.java
Created March 26, 2020 10:33 — 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;