Download csv file and update data

i have a list on google sheet, i want to write an app where members named can download and update "address" and "phonenumber" as csv file and send data back to google sheet

Search through the Extensions category, there are several options for working with google sheets.

1 Like

Maybe I have a similar question: my app uses a local csv file as a database and I need to update it periodically. For now I’m doing this manually recompiling the app every time... Is there a way to update the file automatically retrieving from the web and save it locally? For instance I would like to use a button "check for updates" and make this process more easy.

Where is this file stored? If it is stored in the assets (which are read-only), you must save it in the ASD or one of the Shared folders (/Download or /Documents) first. Or you have to do it online (Google Drive, Firebase, ...).

Thanks Anke. The file is stored in the assets (I want to use my app offline). So how can I change the directory and what should I do next to download a new file and update/substitute the older?

You can copy the csv file from asset to ASD, then edit as text and save to asd

Now the question is: how can I synchronize the last version of the file from an external server and replace the old one automatically, possibly with a button? Many thanks for the help!

:question:

Yes, but as I said I need to upload and replace the csv file periodically without compiling the app every time.

Of course, if this file is hosted (updated) on a server, there is no problem accessing it as long as the device has internet access. So you/the user can download this file (to the ASD or one of the Shared folders) and access it if needed.

What about downloading the file on first run of the app from the internet? Same on button click?

Questions: The server always has the latest version? Which means, you only have to download the latest version? You do not have to upload the file from the app to the server?

Taifun

If the (new, updated) file is already available in the app (i.e. it was created by it), then why upload it to a server (and download it again)?

Probably because several user want to use the same data? I'm just trying to find out the requirements of the project to be able to provide a solution

Taifun

1 Like

Ok, but which device would be the reference device then?

This discussion currently does not make sense... the requirements should be defined before we can suggest solutions

Taifun

1 Like

OK. Sorry for the confusion. I want to point out that I’m not the author of the main topic, my question is only similar.

So let me be clear once again:

  1. YES. my app should download the file from the internet on button click and should update the file that already have in itself (the file must be substitute and remain always there locally and available offline)

  2. YES. the server always have the latest version

  3. NO. I do not have to upload anything

But how does the user know when to press the button and when the Internet connection needs to be active?

In addition:
In case the existing file (in one of the Shared folders) is to be replaced, this file must have been previously created by the app itself, at least on Android 11+. Otherwise it cannot be overwritten on Android 11+. Or the file must be stored in ASD or in PrivateDir (internal storage).

This means for example, that if the app was uninstalled and reinstalled, the existing file can no longer be overwritten on Android 11+ because it was then created by another app (namely the uninstalled app version).

In my case users don’t need to “know”. The button here should be an arbitrary function that just download the latest version of the file and substitute it. That’s all!

The only conditional test could be the availability of the internet connection, like this:

x = file

when Button.Click {

	if (connection) { 
		download file y from server
		substitute file x with y
		alert: “file updated” 
	}
	else { 
		alert: “connection failed”
	}

}

Considering what you said about storing, ASD, etc. could you please help me to translate this logic with a little example in blocks?

Thank you so much for the patience.

In other words, the button must always be pressed in order to carry out any further action. (?)