D
D
Dmitry2015-08-20 11:57:19
Android
Dmitry, 2015-08-20 11:57:19

Writing files in Android KitKat?

I opened my old project, before my application created files in the following way:

final String FilesFolder = Environment.getExternalStorageDirectory().getAbsolutePath()
                                                + File.separator + "Android" + File.separator + "data" + File.separator
                                                + this.context.getPackageName() + File.separator + "files" + File.separator;

File creation
final File imageFile = new File(FilesFolder + (inputData[0].type == ImageProvider.ImageSizeType.FULLSIZE ?
                        "images" + File.separator + imgFileName : "image_miniatures" /*+ File.separator*/ + imgFileName));

permissions are written in the manifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

In Android KitKat, this method does not work - writes access is denied.
How to write files in the latest versions of Android?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2015-08-20
@falcon_sapsan

Solution - stupidly reboot the phone

V
Vladimir Abramov, 2015-08-20
@kivsiak

Of course, I understand the project is old, but Context.getExternalFilesDir(null)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question