It is possible to request a specific file for the user

Asked

Viewed 38 times

0

I want to get a special file from the user. It has how to put the name of this file as type in Intent? For an image for example, use:

Intent intent = new Intent(Intent.ACTION_PICK)
intent.setType("image/*") 
startActivityForResult(intent, 1)

You can set the name of the file I want in setType() to appear only him and the directories? The file is a "backup" of the database called "tobuy.db".

  • Want to validate by mime or extension? If it is by mime just swap the string.

  • @LINQ, but in case I change the string to what? vi que pdf, for example, is used "application/pdf", which I could use as a string to look only for the file "tobuy.db" (or with the extension . db)?

  • I don’t really understand how things work on Android. Tell me: is there any XML (or similar) file attached to the file that contains the code of your question?

  • @LINQ, no, it’s just this code, it basically calls Intent.ACTION_PICK and apps that have activitys that receive this Intent (or something like that) will appear to be chosen (like Manage file or gallery)then I would have to pass setType as an argument for him to know what to show (as only images, for example), so I wanted to let him choose only files with a certain name, but I don’t know if this is possible

  • uses autocomplete and tries to search for some method called setPath, setPathPattern or similar

  • already searched, I saw in the documentation of android and has a list of various types of files and how is the mime of it, but it seems that are for things predefined by the file manager, so I saw there is no way you "create one", but there is and someone answer me right ashuahsuas

  • https://stackoverflow.com/questions/14256537/android-intent-filter-for-custom-file-extension ???

  • @Israelmerljak, actually I wanted the Android File Manager (or the qlqr app Activity that receives this app) to show only files with that extension or name, is it possible or will I have to see if I can find a lib in particular? (or you’ll see there’s no such thing)

Show 3 more comments

1 answer

0


I was able to solve, but it wasn’t through MIME type nor standard managers, I downloaded the aFileDialog library (https://github.com/jfmdev/aFileDialog) and in it you can send the type of extension you want to be shown, there is also how to choose a folder instead of a file, etc. The only harm of the library is that the design is a bit ugly, but as it is open source so you can modify.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.