Is it possible to read csv file pick from ActivityStarter

Hello :slight_smile:

I'm creating a game and i'm working on the capability of exporting the game. The objective of the game is to reach circle that appears in the map, so i export coordinates, gamemode and the score.
To export the game, i export some variables in a csv file named by the user when he share it.
The problem is that when i set the DataType to extension/csv or file/csv i'm unable to pick a csv file. To fix that i try to export in .txt which i can pick but i'm unable to read from the file picked.

My objective here is to make possible to share the exact game to another one user that can upload it from where it is on his phone.

My blocks ( pick the file then read it )


And the error i get on the APK or companion, after chosing the file " share3.txt "

So is that possible to read file not from ASD but from where is the picked file? And if possible make only csv files allowed? After reading multiple post i've found how to change an image after picking or open the file selected with an application but i dont understand how to readfrom this file and create a new game thank's to this.

Thank you :wink:
-Julian

Hi @Narchok Welcome to Community
You can't read a file from Content URI without getting its path.
You should try a File Manager extension.

Thank's a lot! :blush:
I'm going to look for this

Hello Narchok

It may also have something to do with the way you have constructed the file content.

Question - why are you using Activity Starter instead of App Inventor's built-in CSV Blocks?

Hello ChrisWard
The file content is like a csv file with ; separator like this:
boardName;[[55.3,63.1][...]]

I use Activity Starter to use the file explorer in order to pick a csv file anywhere,for now i just want to display the content of the file picked to be sure i can use it.

... so it's not a CSV file because of your format, but if you just read it as a plain text file, you can use the Text Split function to separate the contents.

To recap:
The other Users have the same App.
The App exports data for other Users to import.
Where is the data file sent to? The Cloud (TinyWebDB or similar).
The App will download the data file from the Cloud, storing it in the ASD.
The App can then read the data file from the ASD.

The above may not be true in your case, but this is how you need to inform the Forum so that we understand the goal and can therefore offer advice and help.

First bit of advice: Don't try to save the data file "anywhere". Android is going to prevent Apps from reading from "anywhere" so you are just making more work for yourself without a useful result.

Secondly, take care in defining the data file format (and take care not to misinform the Forum as you have done here!) - it should be as simple as possible. From what I can see, it can be stored as CSV because all the values can be separated by a comma.

Thank's for your answer,
Yes i've explain too fast, let me explain step by step:
-The user play a game, once it's finished the user can share his game with a share component which was at first a csv file ( i change it to txt because I wasn't able to pick a csv file from the file explorer ), so the user share the file by email for example.
-User B receive the file ( now a .txt ) and save it to his phone.
-User B get into the application and run the " upload game button " which call the file explorer, that's why I need to read the file from anywhere. Once the file load, user can play the same game User A played.
Maybe I should copy it to my files/data and then read it? But I still need to be able to find the right path to copy the imported file.
Moreover, I guess now that I'll use txt files to saves games instead of csv ( because I'm unable to load csv files from file explorer even if I change the Activity starter.datatype to file/csv or extension/csv )

You have quite a choice, one of them should work:

text/plain
text/x-csv
application/vnd.ms-excel
application/csv
application/x-csv
text/csv
text/comma-separated-values
text/x-comma-separated-values
text/tab-separated-values

my bet would be for text/csv, however text/plain should return all text files.....

If the file is saved to the ASD, you do not need to use the file explorer. You do need to find a way to exchange data, email would be at the bottom of the list as the Users then have too much to do (though with an extension, copy paste would be possible).

So another question - is this just a private App for you and some friends to play or is it going to be commercial, via Play Store for example. That really determines how the data would be shared.

This is not working even if the MIME type for csv file is text/csv :confused:

I understand that but it's more easy to find it in a folder than replace it to the ASD folder.

This app will be just for friends, and i think we'll share the files with what's app. I just need 5 values to create the same game (boardName,gamemode,polygonPoints,circlePoints,score) that's why i wanted to do it with a file. If you have any another idea on how i can share this data between differents users running the same app, i'll investigate :blush:

I've been able to pick csv file thanks to DeepHost FilePickerExtension and get the filepath to read the data from the file picked but, ReadFrom procedure is failing to read the picked file.



In the previous screenshot you can see in the first label the filepath that allow me to share a file with myself for test, then when i try to click the upload button and select this file i'm unable to read it even if the filepath is the same used for sharing.
It seems like File.ReadFrom read from my app directory and not from root?

Thank's for all the help

You could always try using Taifun's File extension, which returns specific file types:

Just to complete the answer.

It worked! I'm now able to see all csv files and pick one then copy it to the ASD folder. With using the file:/// prefix to find the correct path.


After what i'm able to read it with the ReadFrom procedure. I just need to export data from this file and i'll be fine!
Once again, thank's a lot! :blush:

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