Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i open default Files app with myapp folder programmatically?

I have folder with files in my app. How can i open default Files app with myapp folder programmatically?

This is similar folder of GarageBand App in Files.

enter image description here

like image 504
alexbayker Avatar asked Apr 19 '26 09:04

alexbayker


1 Answers

You can open Files app in specific folder using shareddocuments: URL scheme and providing file path.


Example:

func getDocumentsDirectory() -> URL { // returns your application folder
    let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
    let documentsDirectory = paths[0]
    return documentsDirectory
}

let path = getDocumentsDirectory().absoluteString.replacingOccurrences(of: "file://", with: "shareddocuments://")
let url = URL(string: path)!

UIApplication.shared.open(url)


P.S:

For more information, read this article.

like image 64
えるまる Avatar answered Apr 21 '26 01:04

えるまる



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!