• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Copy images from gallery in app directory targetSDKVersion > 28

Hallo, sorry for my bad english.

I have problems with the value "targetSdkVersion" in the build.gradle related to copying images from the Gallery to my APP directory. The background is that I use MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA take several pictures in a row with the camera APP and then display them in a list. Unlike with MediaStore.ACTION_IMAGE_CAPTURE you can't save the pictures directly here and with the second you can only take a picture.

If set the value 28 as targetSdkVersion, I can easily copy images from the Gallery to my APP directory (after appropriate permission) and no more at 29 (otherwise no change). srcFile.exist() returns true at both values, FileTools.fileCopy(src,dest) returns true at value 28 and the file is copied. If 29 is a value, the value is returned false and the file is not copied. The app needs to be uninstalled and reinstalled once when changing values, there are no problems with the update from 28 to 29.
I think this has something to do with it, as can be seen from https://developer.android.com/distribute/best-practices/develop/target-sdk.
• Scoped storage
• External storage access is limited only to an app-specific directory and to specific types of media that the app has created.

Does anyone have an idea what alternative I have to copy the images from the DCIM directory to my app directory. Other apps do the same.

greetings Jens
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones