Bonjour à tous,
voici mon soucis et mon questionnement:
Projet: Je voudrais récupérer le path d'un fichier pour entre autre l'afficher dans un textview.
J'utilise ce code pour lancer une intent avec createchooser. La fenêtre proposant les explorateurs de fichiers s'ouvrent bien:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 Intent fichier = new Intent(Intent.ACTION_GET_CONTENT); Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()); fichier.setDataAndType(uri, "*/*"); startActivity(Intent.createChooser(fichier, "selectionner votre fichier avec:"));
Je voudrais donc pouvoir récupérer le path du fichier qui est ensuite sélectionné avec l'application sélectionnée.
Mais comment faire? Est-ce possible?
Voici ce que dit la bible:
http://developer.android.com/trainin...uest-file.htmlAccess the Requested File
The server app sends the file's content URI back to the client app in an Intent. This Intent is passed to the client app in its override of onActivityResult(). Once the client app has the file's content URI, it can access the file by getting its FileDescriptor.
File security is preserved in this process because the content URI is the only piece of data that the client app receives. Since this URI doesn't contain a directory path, the client app can't discover and open any other files in the server app. Only the client app gets access to the file, and only for the permissions granted by the server app.
Si quelqu'un pouvait m'aiguiller....
Merci d'avance
Partager