I am working with ArcGIS sdk for android and it has a method called RouteTask.createLocalRouteTask Which takes the path of a folder as one of its argument.And That folder should contain 6 files inside of it.So how am I suppose to give the path of that folder which is inside my asset folder.
The folder name is arc and this is what my structure looks like
the above answers are going to help u if u use the stream to copy your file from asset folder to the external storage by checking if it does not exist in ur external storage device.How to copy files from 'assets' folder to sdcard?
You can give path of assets folder like this:
file:///android_asset/<folder_name>/<file_name>
In your case it, will be
file:///android_asset/arc/Navigation_ND_schema
you can access folder inside the asset folder like this:
file:///android_asset/" + "folder Name/"+"fileName.extension"
Related
I have created 2 directories in the assets folder.
One is android and second is window.
--assets
1:- android
2:- window
I have a few files inside in the android folder. I need to copy all of them from the android folder to the window folder at runtime. How do I do it?
You can't. The assets folder is read-only and cannot be modified after compilation.
You can copy your files into a similar structure on the internal storage if you wish to do so.
I had searched to create the assets folder in an android app, the solution which i had tried is <App Name>/src/assets/fonts/
but when i try to use a ttf file in my Application, i have an error :
the code :
mFace = Typeface.createFromAsset(mContext.getAssets(),"fonts/fontType.ttf");
and the error :
native typeface cannot be made
I don't know if the assets folder is in the good place.
The problem is at the path of asset
<App Name>/src/assets/fonts/
should be
<App Name>/assets/fonts/
Read more at Directory Structure of an Android Project
Android project directory structure is as below
In Android Studio, I tried the root "app" folder, and that didn't work. I looked for the AndroidManifest.xml file and put the assets folder there. That worked for me.
For me it ended up being app\src\main\assets
ProjectName/assets/fonts
Not in under the src.
The assets folder is an independent folder.
While creating an Android project itself the Assets folder is independent to the src folder. Not inside the src folder.
Confirm that assets folder was created in the following way /assets.
Later create a fonts folder inside the assets folder and place fonts file inside the fonts : /assets/fonts
I have a few thousand image files in a directory structure. There are a few hundred different subdirectories and each directory contains 10 images named 1.png - 10.png...
How can I add these folders to my app and access these images? Assuming I want foo/bar/1.png?
In android it doesn't appear like you have a string path to your assets or raw directories so I have no clue how I would do this. Please don't tell me I have to zip them then unzip them out of assets.
In android it doesn't appear like you have a string path to your assets
Sure you do. getAssets().open("foo/bar/1.png") will give you an InputStream to that PNG file, assuming that your project has assets/foo/bar/1.png in it. You can then use BitmapFactory to read it in.
However, resources cannot exist in subdirectories. You could write a script on your development machine that flattens the structure (e.g., foo/bar/1.png into foo_bar_1.png), then put the renamed files into whichever res/drawable-NNNN/ directory is appropriate.
the path to access the android asset folder is :
file:///android_asset/filename
You should be able to access a folder with :
file:///android_asset/folder1/folder2/targetFolder/
Note that there is 3 '/' after 'file:'
I can open my file using an asset manager, it is located under assets, I was just wondering if i could get the files id (so I can use it with sound pool) and if it was possible to copy from assets folder to raw folder at runtime (dont ask me why I want to do this).
Thanks
No, it is not possible to copy from assets to raw folder at runtime. Don't ask me why.
you can copy the file into raw folder why you use the assets folder. if your application run with raw folder then no need to store the file on assets. there is no way to copy the assets file to any other folder.
I just want the path of the assets directory which I want to use as a variable throughout my app.
I know we can refer a file in the "assets" directory using AssetManager, but I don't want to refer a file as of now, I just want the path of the assets directory.
Can anybody help me with this?
I just want the path of the assets directory which I want to use as a variable throughout my app.
There is no "path of the assets directory" on the device.
I know we can refer a file in the "assets" directory using AssetManager, but I don't want to refer a file as of now, I just want the path of the assets directory.
There is no "path of the assets directory" on the device.
Can anybody help me with this?
No, because there is no "path of the assets directory" on the device. Please use AssetManager to retrieve an InputStream to your assets as needed.
Since android has a file size restriction on files inside raw directory, I will be placing my files in assets directory, and during runtime, I would be retrieving them as need
The "restriction" is the same for assets, AFAIK. The usual way to circumvent the "restriction" is to give the file an extension that Android's build tools will not try to compress (.mp3 works IIRC).
Try using
AssetFileDescriptor