Office Hours — Today, November 1

Tuesday, October 30

Nov 1
8:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
9:10 AM
Ed T.
has entered the room
Ed T.
Good morning Mark
Mark M.
hello, Ed!
how can I help you today?
Ed T.
if I save a temp file to share it with another application as a viewer.... what is the best way to insure I delete the temp file after my application exits?
Is it save to delete it after the intent is passed? I didn't think that would be wise.
Mark M.
no, because you do not know when the other app is done with it
that's a general problem with this sort of inter-app content sharing
are you using FileProvider?
Ed T.
looking....
Yes, I'm actually using your example version
Mark M.
usually what I recommend is having some sort of policy (e.g., the file is no longer needed after 24 hours) and some trigger for implementing the policy (e.g., will check on each app launch, will use JobScheduler to check every day)
in particular "after my application exits" is not a good policy (the other app might still be using it) nor a good trigger (as you don't reliably get control at that point)
9:15 AM
Ed T.
Good to know
another question along these lines... assume I have a temp file I allow them to view but it is only uses within the app.
what is the best practice to delete or purge this temp file, if it isn't used by any other application?
Mark M.
worst-case, you take the same approach that I described
if you know somewhere in the flow of your app that you are definitely done with the file, delete it then
this sort of thing tends to be driven a lot by app requirements, and I don't know much about your scenario
Ed T.
so when the viewer screen is destroyed or they leave that screen ?
Mark M.
if there is no way for them to get back to there where they would need that data, that would be a reasonable trigger
Ed T.
thanks Mark!
I didn't think it would be wise to delete it if they exported the file to an external viewer
appreciate your time
Mark M.
I draw a distinction between "user exported" and "the app happens to make it available"
9:20 AM
Mark M.
if the user is explicitly saying "I want this data to be visible to the other app", perhaps the answer is that you let the user choose where to save that data (e.g., ACTION_CREATE_DOCUMENT), after which it is up to the user to get rid of it
Ed T.
great point
Ed T.
has left the room
10:00 AM
Mark M.
turned off guest access

Tuesday, October 30

 

Office Hours

People in this transcript

  • Ed Tidwell
  • Mark Murphy