How to get FileInputStream for internal memory files in Android? The file is in my user folder made in the application space

How to get a FileInputStream for a file in internal memory in android that is not inside the default files directory files.

I created a new directory in my application space. Thus, openFileInput("filename") will only work for files in getFilesDir() . And openFileInput("filename") does not accept the argument with path separators "/", so I can change it to .. / myfolder /.

Is there a way to get a FileInputStream on this? ..

Note. Using the regular APIs File = new File (...) gives the allowed deviations. And I already created this Context.MODE_WORLD_WRITEABLE as permission for my custom folder.

To make it clear: My file is here ==> /data/data/com.app.package/app_myfolder/file1.tmp where "myfolder" ==> is created with permissions Context.MODE_WORLD_WRITEABLE .

I want to open FileInputStream on file1.tmp . (Usually your files here /data/data/com.app.package/files/file1.tmp and getFilesDir() point to this directory, so openFileInput("") takes an argument that exists in the same directory by default.)

+4
source share
1 answer

How to get a FileInputStream for a file in internal memory in android that is not inside the default file directory.

You cannot if this file is not created using openFileOutput() with MODE_WORLD_READABLE , and this is not a good idea (since any application can now read this file).

Since the file was created by camera activity as a result for the startActivityForResult () function for MediaStore.ACTION_IMAGE_CAPTURE.

Camera activity should store the file in external storage, not in internal storage. Use EXTRA_OUTPUT additionally to indicate where the file should go.

So can these permissions be changed?

Assuming that “camera activity” refers to what is contained in the Android firmware, you will need to change the firmware.

0
source

Source: https://habr.com/ru/post/1335034/


All Articles