I get media path of image in nativescript
my code:
var logoPath = argIntent.getParcelableExtra(Intent_1.EXTRA_STREAM);
but I get this path:
content://media/external/images/media/152
How to get absolute path including the file name from this path??
In Nativescript/Javascript implementation please! if there is some kind of code ..
--
I need something like this, but in javascript code:
public static String getRealPathFromURI_API19(Context context, Uri uri){
String filePath = "";
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();
return filePath;
}
How I can rewrite it!?
String path = yourAndroidURI.uri.getPath() // "file:///mnt/sdcard/FileName.mp3"
File file = new File(new URI(path));
or
String path = yourAndroidURI.uri.toString() // "/mnt/sdcard/FileName.mp3"
File file = new File(new URI(path));
also refer this link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.