Skip to content

Instantly share code, notes, and snippets.

@makorowy
Created February 25, 2018 18:46
Show Gist options
  • Save makorowy/36ccdcb33cde209f7a7e3f8247c069e3 to your computer and use it in GitHub Desktop.
Save makorowy/36ccdcb33cde209f7a7e3f8247c069e3 to your computer and use it in GitHub Desktop.
TensorFlow - Hot or Not example. Creating an Uri from a file path.
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