Save file to internal storage

Is there a way to save to internal storage?

Yes you can

You might want to elaborate, what exactly you are trying to do...

See also

Taifun

1 Like

I am trying to create a csv file for my app but it won't create the file. I have seen a lot of forum threads and have found no solution. Please help me! I don't have an sd card on my phone so I don't know if that is the reason why or not. But here is my code and I wanted to know if there is anything wrong with it.

Read this first to understand the difference between external and internal storage and then specify your question.

1 Like

Okay, I am creating an app that creates football (soccer) statistics. I capture the 1st and 2nd half stats and add them to a label that is then created into a csv file.

I have tried creating the file but it hasn0t worked yet.

You are not able to store in arbitrary directories anymore... try storing to shared storage... for example /Download

Taifun

1 Like

Okay, I changed the directory to /Document, that should be okay yes? And the DefaultFileScope shoulb be set to shared right?

Thank you! I understand now what External storage means

Hello Filipe

Google introduced security measures that prevent Apps making their own directories/files on SD. Where you save your file depends on it's purpose. If it is to be read on your device by another App, it needs to be saved to a shared directory. If it is only for your App to read, save it in the ASD (App Specific Directory).

Guide:

1 Like

Should be /Documents.

1 Like

Yes, you're right. I misspelled the word.

No, it must be Legacy, because on Android 11+ WRITE permission must also be (incorrectly) declared in the Manifest. And this is the only option that does this.

Or you can use my MFile extension.

Search the forum, I've pointed out this bug countless times and how to work around it.

1 Like

I'm going to use the MFile extension, it seems better to use. Could you please explain to me what I have to do to make it work?

Take a look at the blocks I've shown in the description of the extension:

1 Like

Sorry for asking but what does the mfile.sdkversion mean?

API level (Android version) of the device.
Example: If API < 30 (Android < 11), then ask for WRITE permission.

grafik

Read this for deeper understanding:

Create a new Forum Topic for this issue Filipe.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.