mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Removing unnecessary old class
This commit is contained in:
parent
a51de811f7
commit
7fea299047
1 changed files with 0 additions and 56 deletions
|
|
@ -1,56 +0,0 @@
|
||||||
package fr.free.nrw.commons.upload;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.provider.DocumentsContract;
|
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class FilePathConverter {
|
|
||||||
|
|
||||||
private Uri uri;
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
public FilePathConverter(Context context, Uri uri) {
|
|
||||||
this.context = context;
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets file path of image from its Uri
|
|
||||||
* May return null
|
|
||||||
*/
|
|
||||||
public String getFilePath(){
|
|
||||||
|
|
||||||
String filePath ="";
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Will return "image:x*"
|
|
||||||
String wholeID = DocumentsContract.getDocumentId(uri);
|
|
||||||
|
|
||||||
// Split at colon, use second item in the array
|
|
||||||
String id = wholeID.split(":")[1];
|
|
||||||
String[] column = {MediaStore.Images.Media.DATA};
|
|
||||||
|
|
||||||
// where id is equal to
|
|
||||||
String sel = MediaStore.Images.Media._ID + "=?";
|
|
||||||
Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
|
||||||
column, sel, new String[]{id}, null);
|
|
||||||
|
|
||||||
int columnIndex = cursor.getColumnIndex(column[0]);
|
|
||||||
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
filePath = cursor.getString(columnIndex);
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
|
|
||||||
Log.d("Image", "File path: " + filePath);
|
|
||||||
return filePath;
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Log.w("Image", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue