Having trouble with my app reading files on my phone

I am trying to read data from an csv file on my phone. I had worked previously and all of a sudden stopped working. I have tried multiple things to try and get it working now, but I can't figure out what's wrong.

Below is my code

  • do you get error messages?
  • what is specifically not working? adding csv file, adding to the file, reading the file or what?
  • did you make an aia of the Project while it was still running correctly? If so have you tried loading the aia and does it still work? Is the issue that the location is not changing or something else? If location is not changing is your Android setting on your desk?

Not easy to provide advice on an app like this by inspection and without an aia. However note you are not adding the FineLocation permission in the right place for Android versions 11+. I see no place where you are saving your File or the name of the saved File. Your while test code looks suspicious. :cry: Your File1.GotText sets sets your global Location to two different values, which is the one you want to locate as Location? Where do you link your LocationSensor to the Map component?

Did you use debugging procedures to find out what part of your app is broken. Did you use DoIt ?

I said I was trying to reading a csv file. An error message always pops up saying that it can't find the file and will include the given path. The path is Documents/AppInventor/locations.csv. Yes, I did make a project and it was working. How else would I get the screen shot of the code? I used a button to be able to attempt to read the file on press.

Also where should put the permission for the fine location for Android 11+ versions?

The Blocks do not seem to have code showing where you save the File . If the file is not where you told your app to place it, it probably won't be there . :cry:

Alternatively, you could save your Locatiions to a TinyDB tag. That might be easier to use than the File component.

1 Like

I don't understand what you mean by where to place the file. There is a file only meant to be read that is already going to be on the device. There is no reason for use to have to save it. Unless that is what must be done to read it. Please let me know if that is the case.
Here is the file location/path.

You have not provided a FULL file path. A full path might be required.

Perhaps this will work file:///storage/emulated/0/Documents/AppInventor/locations.csv as a guess.

I had used the method where it can print the full path. I used it but its not working. I just wonder if it just because of android updates. It was working perfectly fine with "/Documents/locations.csv". If it helps the time it changed was when I had added a formula to the button click.

Where does this CSV file come from, who created it and when? If the file was previously already created with Companion (that is, by the app itself), it cannot be accessed (read) later with the compiled app (APK) - at least not on Android 11+, since the APK is a different app . The same applies if the app is uninstalled and reinstalled again. To catch such problems, it is helpful from Android 11 to add a time stamp to the file name. Otherwise SAF must be used.

See also here:

1 Like

Okay I read the link and I think I have decided to use SAF. I am just a little confused on how to use it. On how to get the Uri or even to get to documents.