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.
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 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"
I am making hybrid application.I have one file in this directory assest->www->ATMS.html or other js files.So I load in web view like this.
web.loadUrl("file:///android_asset/www/a.html");
I want to copy all file files and folders which is inside the asset folder.Instead of loading from assest folder .I need to load from copy folder.As some some told me that there is file system of APK file.Mean we can copy all files in apk file system .and load html from that APK file system .
There is few link give information to copy of assest folder
How to copy files from 'assets' folder to sdcard?
But I don't get knowledge how to copy in APK file system .Mean when Aplication uninstall it remove the copied folder .When application launch it make copy of assest folder in apk file system ..
thanks
Not sure I get your question fully right as explanation is bit messy, but while APK is ZIP file, you should really consider it read-only. So you can copy files out of it but you cannot add anything to your APK nor alter it at runtime.
I want to add a text file to my APK root. This file will not be used in the application but it will stay there for manual extraction of the APK.
I tried to put it into the root of the project in Eclipse but it didn't include that file in the APK. I don't want to put it into assets folder. Can't I put it to the root?
Use the assets folder.
According to Android developer
assets/
This is empty. You can use it to store raw asset files. Files that you save here are compiled into an .apk file as-is, and the original filename is preserved. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager. For example, this is a good location for textures and game data.
Files that are not put into any of the main directories of your android project will NOT be included in your apk. You MUST put the file in the assets so it can be accessed within the application as an external resource/file.
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