ilan Expert Licensed User Longtime User Mar 26, 2018 #1 hi i have uploaded my old app to use FileProvider to upload or share files (as erel suggested) my problem is that i am using backup files to backup all my data and allow to upload to google drive or share with any other option like email,.. i also save the file in the shared folder (shared = rp.GetSafeDirDefaultExternal("shared")) to let the user restore all his data to a previous point by loading an older backup. anyway, everything is working fine my only problem is that when the user has deleted the app accidentally the all files in that shared folder are deleted. what possibilities do i have now? should i go back to "File.DirDefaultExternal" ?? my second question is. i used this code in the past to show an image with the default gallery viewer Code: Copy ' Dim i As Intent i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(Starter.shared, uri)) i.SetType("image/*") StartActivity(i) but now its not working anymore, how can i use FileProvider for this? i tried this but i get a message that the file was not found. but the file is there i even get true if i check if the file exists. Code: Copy Dim i As Intent i.Initialize(i.ACTION_VIEW, CreateFileProviderUri(Starter.shared, uri)) i.SetType("image/*") 'it is not related to the file itself. StartActivity(i)
hi i have uploaded my old app to use FileProvider to upload or share files (as erel suggested) my problem is that i am using backup files to backup all my data and allow to upload to google drive or share with any other option like email,.. i also save the file in the shared folder (shared = rp.GetSafeDirDefaultExternal("shared")) to let the user restore all his data to a previous point by loading an older backup. anyway, everything is working fine my only problem is that when the user has deleted the app accidentally the all files in that shared folder are deleted. what possibilities do i have now? should i go back to "File.DirDefaultExternal" ?? my second question is. i used this code in the past to show an image with the default gallery viewer Code: Copy ' Dim i As Intent i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(Starter.shared, uri)) i.SetType("image/*") StartActivity(i) but now its not working anymore, how can i use FileProvider for this? i tried this but i get a message that the file was not found. but the file is there i even get true if i check if the file exists. Code: Copy Dim i As Intent i.Initialize(i.ACTION_VIEW, CreateFileProviderUri(Starter.shared, uri)) i.SetType("image/*") 'it is not related to the file itself. StartActivity(i)
Erel B4X founder Staff member Licensed User Longtime User Mar 27, 2018 #2 ilan said: should i go back to "File.DirDefaultExternal" ?? Click to expand... It will not help. They point to the same path. You can use a custom folder under File.DirRootExternal. The folder will not be deleted. It requires acquiring the storage permission. ilan said: but now its not working anymore, how can i use FileProvider for this? Click to expand... What is uri? I guess that the file was not copied to the correct location. Upvote 0
ilan said: should i go back to "File.DirDefaultExternal" ?? Click to expand... It will not help. They point to the same path. You can use a custom folder under File.DirRootExternal. The folder will not be deleted. It requires acquiring the storage permission. ilan said: but now its not working anymore, how can i use FileProvider for this? Click to expand... What is uri? I guess that the file was not copied to the correct location.
ilan Expert Licensed User Longtime User Mar 27, 2018 #3 Erel said: You can use a custom folder under File.DirRootExternal Click to expand... I did it like that before but now i target sdk26 so i guess i will need to use runtime permission right? Erel said: What is uri? I guess that the file was not copied to the correct location. Click to expand... No the path is correct it is working with target sdk 19. Now i use target sdk 26 so maybe i need to use runtime permission for that? Uri points to the shared folder (safe folder) as in your example code of file provider. Upvote 0
Erel said: You can use a custom folder under File.DirRootExternal Click to expand... I did it like that before but now i target sdk26 so i guess i will need to use runtime permission right? Erel said: What is uri? I guess that the file was not copied to the correct location. Click to expand... No the path is correct it is working with target sdk 19. Now i use target sdk 26 so maybe i need to use runtime permission for that? Uri points to the shared folder (safe folder) as in your example code of file provider.
Erel B4X founder Staff member Licensed User Longtime User Mar 27, 2018 #4 ilan said: I did it like that before but now i target sdk26 so i guess i will need to use runtime permission right? Click to expand... Yes. ilan said: Now i use target sdk 26 so maybe i need to use runtime permission for that? Click to expand... If you are only using GetSafeDirDefaultExternal then you don't need any permission. Upvote 0
ilan said: I did it like that before but now i target sdk26 so i guess i will need to use runtime permission right? Click to expand... Yes. ilan said: Now i use target sdk 26 so maybe i need to use runtime permission for that? Click to expand... If you are only using GetSafeDirDefaultExternal then you don't need any permission.