Created
February 25, 2018 18:46
-
-
Save makorowy/36ccdcb33cde209f7a7e3f8247c069e3 to your computer and use it in GitHub Desktop.
TensorFlow - Hot or Not example. Creating an Uri from a file path.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object UriHelper { | |
fun getUriFromFilePath(context: Context, filePath: String): Uri { | |
val file = File(filePath) | |
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
FileProvider.getUriForFile( | |
context, | |
context.applicationContext.packageName + ".uri", | |
file) | |
} else { | |
Uri.fromFile(file) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment