Skip to content

Commit

Permalink
fix(android): cpExternal error on pre API 29
Browse files Browse the repository at this point in the history
Closes #20
  • Loading branch information
alpha0010 committed May 3, 2021
1 parent 018eb13 commit 5e6187a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion android/src/main/java/com/alpha0010/fs/FileAccessModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,21 @@ class FileAccessModule(reactContext: ReactApplicationContext) : ReactContextBase
"audio" -> {
reactApplicationContext.contentResolver.insert(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
ContentValues().apply { put(MediaStore.Audio.Media.DISPLAY_NAME, targetName) }
ContentValues().apply {
put(MediaStore.Audio.Media.DISPLAY_NAME, targetName)

if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.Q) {
// Older versions require path be specified.
@Suppress("DEPRECATION")
put(
MediaStore.Audio.AudioColumns.DATA,
File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC),
targetName
).absolutePath
)
}
}
)
}
"images" -> {
Expand Down

0 comments on commit 5e6187a

Please sign in to comment.