Reset button results in error with creating a csv file in internal storage

Hi, I'm having some trouble coding the reset button on my app.

So the app is to collect sensor data over bluetooth which can then be saved into the internal storage section as an csv. The app is overall functioning and able to collect data and able to save the file. However, when I press the reset button, everything seems to reset except for the creation of a file in the internal storage. I get the error that the file cannot be created. The settings is fine if I exit the app and reconnect the bluetooth, but I want to be able take a new reading and save it as a new file when I click the reset button.

I wasn't able to find a similar topic in the Help section, but if there is, please forward it on. Any help is highly appreciated.

These are the block I've used to save the file:
image

if the file already exists, you can't create it again, you first have to delete it
Or is the filename always different?
can you provide a screenshot of the exact error message?

Taifun

The filename changes as the name contains the current time. The error I get is 2103: The file/storage/emulated/0/Data_(current time).csv could not be created. The rest data that is being streamed is still being monitored but I can't view or save the file.

According to the error message you are trying to store a file in the root directory of the internal sdcard... this is not possible... see also Some basics on Android storage system

Taifun

Try using filescope legacy and /Documents (not Documents)

Hi sorry, I don't think I understand what you mean. I have it set on legacy, but what do you mean by the documents?

Hi Taifu,

I'm just struggling to understand why it saves the first time but has the error once I reset. I'm storing it in the internal storage, not the SD card

Are you sure you know what's the internal storage ? Change your block so

Show the relevant blocks that are responsible for this error (2103).
grafik

These blocks are not:

It doesn't make a difference either way. The file is saved in the same location.

These are my blocks for creating the file


and here are my reset blocks

image

I saved the data in ASD originally and then read the file into a label and then saved the label under a specific file name in the internal storage as excel sheets with the date and time as the file name.

Thank you

These blocks do not save anything
Somewhere in your blocks you are trying to store the file in the root directory of your internal (emulated) sdcard, which is /storage/emulated/0

Taifun

1 Like