How To Get The Path To The Android Assets Folder In The Application Package
I have a whole folder structure that I want to copy from my assets folder. However, the mContext.getAssets().open() seems to only want a filename so that it can return an InputSt
Solution 1:
AssetManageram= con.getAssets();//u have get assets path from this codeInputStreaminputStream=null;
inputStream = am.open("file.xml");
or
String file_name="ur.xml"
inputStream = am.open("foldername/"+ur);
Solution 2:
Could you move the folder to your /raw folder? Then you could use:
com.your.package:raw/yourFile
Like this:
intresourceId= context.getResources().getIdentifier("com.your.package:raw/somefile.txt");
Filef=newFile(context.getResources().openRawResource(resourceId));
And here's someone doing it with the assets folder:
Android Assets with sub folders
InputStream is = getAssets().open("subfolder/somefile.txt");
Solution 3:
Use file:///android_asset
for accessing the asset folder and then you can always give your subfolder there.
AssetManagerassetManager=null; // null ??? Get the AssetManager here.AssetFileDescriptorassetFileDescriptor=null;
try{
assetFileDescriptor = assetManager.openFd("file:///android_asset/yourfolder/file");
FileDescriptorfd= assetFileDescriptor.getFileDescriptor();
} catch (Exception e){}
Post a Comment for "How To Get The Path To The Android Assets Folder In The Application Package"