how to make copy asset folder in apk directory? - android

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.

Related

Delete android file located in raw or assets directories

I make android application that read file.txt from resource/raw by context?.resources?.openRawResource(R.raw.file), and it's work fine.
I have tried assets directory by : context?.assets?.open("file.txt") and it's work also.
Now, I need to delete this raw/assets resource file or delete the content. Is there anyway to do it with android code?
No, there is no way to update the Assets or Raw files.
Both of them are read-only.
What you can do, it's to make a copy of the file in a writable directory and modify them as needed.
UPDATE
Just to give more context, both assets and any resources are part of the binary file (APK or app bundle). As they come as part of the package you cannot change them without creating a new binary.

Why can't I see `assets` folder in my Android package installation folder

I'm browsing with DDMS my application's installation folder /data/data/com.my.app and I can't find where the assets folder is. I'm using it inside my application using URI file:///android_assets/...
I can't find where the assets folder is
That is because there is no assets folder on the device. The assets, like your resources, are packaged into the APK file. Assets are not unpacked as part of APK installation. file:///android_asset/, for those things that understand it, knows to look inside of the assets in your APK.

How to put extra files in Android APK with Eclipse?

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.

add custom .properties file in unity android package

I have a .properties file that is required by some android java unity plugin that I am writing. I need to add this file to the unity app's package somehow, so once the unity IDE builds the .apk, the file is located in the root of the apk's assets folder.
Where and how do I place this file in the Unity IDE? I tried putting it under Assets, but I inspected the resulting .apk file and the file did not make it there..
any ideas?
tnx
You have two options for including files accessible at runtime:
Managed assets in Ressources folders accessible via Resources.Load
Un-managed assets in the StreamingAssets folder accessible via the File or WWW APIs
Your .properties file should probably reside in the StreamingAssets folder, if you don't need Unity3D to process it. Unity3D will optimize assets in the Resources folders. For example an image will have to set as GUI or Texture in the IDE. Assets in the StreamingAssets folder are raw and not processed by the Unity3D IDE. So a png is a still a regular png at runtime. StreamingAssets is where we store mp4 mobile videos we don't want Unity3D to re-encode.

Asset manager, get asset id?

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.

Categories

Resources