|
|
@ -102,8 +102,6 @@ object RealPathUtil { |
|
|
|
val projection = arrayOf( |
|
|
|
val projection = arrayOf( |
|
|
|
column |
|
|
|
column |
|
|
|
) |
|
|
|
) |
|
|
|
var input: FileInputStream? = null |
|
|
|
|
|
|
|
var output: FileOutputStream? = null |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
cursor = |
|
|
|
cursor = |
|
|
|
context.contentResolver.query(uri!!, projection, selection, selectionArgs, null) |
|
|
|
context.contentResolver.query(uri!!, projection, selection, selectionArgs, null) |
|
|
@ -115,6 +113,8 @@ object RealPathUtil { |
|
|
|
e.printStackTrace() |
|
|
|
e.printStackTrace() |
|
|
|
val file = File(context.cacheDir, "tmp") |
|
|
|
val file = File(context.cacheDir, "tmp") |
|
|
|
val filePath = file.absolutePath |
|
|
|
val filePath = file.absolutePath |
|
|
|
|
|
|
|
var input: FileInputStream? = null |
|
|
|
|
|
|
|
var output: FileOutputStream? = null |
|
|
|
try { |
|
|
|
try { |
|
|
|
val pfd = |
|
|
|
val pfd = |
|
|
|
context.contentResolver.openFileDescriptor(filePathUri!!, "r") |
|
|
|
context.contentResolver.openFileDescriptor(filePathUri!!, "r") |
|
|
@ -127,11 +127,12 @@ object RealPathUtil { |
|
|
|
while (input.read(bytes).also { read = it } != -1) { |
|
|
|
while (input.read(bytes).also { read = it } != -1) { |
|
|
|
output.write(bytes, 0, read) |
|
|
|
output.write(bytes, 0, read) |
|
|
|
} |
|
|
|
} |
|
|
|
input.close() |
|
|
|
|
|
|
|
output.close() |
|
|
|
|
|
|
|
return File(filePath).absolutePath |
|
|
|
return File(filePath).absolutePath |
|
|
|
} catch (ignored: IOException) { |
|
|
|
} catch (ignored: IOException) { |
|
|
|
ignored.printStackTrace() |
|
|
|
ignored.printStackTrace() |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
input?.close() |
|
|
|
|
|
|
|
output?.close() |
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
cursor?.close() |
|
|
|
cursor?.close() |
|
|
|