2017-03-09 1 views
0

Salut, je veux le chemin d'accès à un fichier dans mon dossier d'actifs android.Comment puis-je obtenir le chemin du fichier d'actif en tant que chaîne?

Comment obtenir le chemin en tant que chaîne?

J'essaie avec:

String path = getClass().getClassLoader().getResource("file:///android_asset//psp.pdf").getPath(); 

J'ai besoin du chemin comme String.

+1

réponse possible http://stackoverflow.com/questions/8474821/how-to-get-the-android-path-string-to-a-file-on-assets-folder. Ce n'est pas possible. –

+0

http://stackoverflow.com/questions/4820816/how-to-get-uri-from-an-asset-file –

+1

Copie possible de [Comment obtenir la chaîne de chemin android à un fichier sur le dossier Assets?] (Http : //stackoverflow.com/questions/8474821/how-to-get-the-android-path-string-to-a-file-on-assets-folder) –

Répondre

1

Les seules façons d'accéder à un actif sont:

  • Via open() sur AssetManager, dans ce cas, votre chemin est psp.pdf

  • Via file:///android_asset/ dans WebView, dans ce cas, votre chemin est file:///android_asset/psp.pdf

Un actif n'est ni un fichier sur un fil esystem ou quelque chose que vous obtenez d'un ClassLoader.