Post your questions and help other users.
Moderator: Martin
-
clive.pottinger
- Posts: 21
- Joined: 16 May 2014 13:18
Post
by clive.pottinger » 16 May 2014 13:43
Hello folks,
I am new to world of Android programming and I am having some trouble figuring out how to get Automagic to do two tasks:
- I would like to be able to tell if a particular file exists
- I would like to be able to delete a particular file
The context for this is I have a flow that automatically stops my Gleeo time tracking when I disconnect from the WiFi at work. I would like to add the ability to export that day's activity from Gleeo, and when I arrive at work the next morning, have that file automatically (sorry, automagically) e-mailed to me (so I can transfer the information into the time tracker used by the company), and then delete it. I just don't see how to tell if the file is there, and how to delete it after e-mailing it.
Any help would be greatly appreciated.
-
Martin
- Posts: 4468
- Joined: 09 Nov 2012 14:23
Post
by Martin » 16 May 2014 14:15
Hi,
There are different ways to do this:
-condition Expression: existsFile("/storage/emulated/0/file.csv")
-->true: -action Delete Files: /storage/emulated/0/file.csv
or
-action Init Variables File Info: /storage/emulated/0/file.csv, activate the file_exists check box
-condition Expression: file_exists
-->true: -action Delete Files: /storage/emulated/0/file.csv
or
You could also try to delete the file and handle the exception if it does not exist:
-action Delete Files: /storage/emulated/0/file.csv
--Exception--> -action Notification on Screen: Failed to delete file, probably does not exist
You can create the exception-connection by adding a second action with the (+)-icon as usual, then select the connection, press the edit-icon and switch the type of the connection to Exception. Automagic will only execute the second action when the first one was not successful.
Regards,
Martin
-
clive.pottinger
- Posts: 21
- Joined: 16 May 2014 13:18
Post
by clive.pottinger » 19 May 2014 02:19
Thank you, Martin.
That was exactly what I was looking for. I used the first two examples you gave, and now I get yesterday's information e-mailed to me as soon as I get to work in the morning.
Thanks again.