I use StreamingAssets for my Android Game,
And would like add files in StreamingAssets folder after installation of APK,
But I don't know where is the location of this folder.
Can you help me ?
You can not add or modify files that are inside the streaming assets folder after building since on almost all platforms the directory is read only. From the docs:
On many platforms, the streaming assets folder location is read-only; you can not modify or write new files there at runtime. Use Application.persistentDataPath for a folder location that is writable.
That said, on Android the filepath to the streaming assets is at "jar:file://" + Application.dataPath + "!/assets, from the same docs:
Android uses files inside a compressed APK
/JAR file, "jar:file://" + Application.dataPath + "!/assets".
Do note that you can not access this file location through the standard C# File functions, but need to access it using a webrequest.
If you need a directory to store data during run time you need to use the Application.persistenDataPath instead.
From the docs:
This value is a directory path where you can store data that you want to be kept between runs. When you publish on iOS and Android, persistentDataPath points to a public directory on the device. Files in this location are not erased by app updates. The files can still be erased by users directly.
You don't do this after build.
Create StreamingAssets directory inside Unity Editor in your Assets/ directory and add all your files there. They will be included in build automatically.
If you need this because of the .apk size limitation on Play Store then you can create an .obb file with all of the additional assets (including the ones in SteamingAssets directory). Check it here - https://docs.unity3d.com/Manual/android-OBBsupport.html.
Related
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 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.
I have a directory which contains some files. I want to bundle this directory inside apk file so that when I install apk file the directory gets copied to a particular location on the android device.
Can I bundle a directory inside apk file as I didn't find this information on developer.android.com? Do I need to modify any configuration file for this?
Thanks..
Ajay
You cant, but you could take a look at the android assets folder,
http://developer.android.com/guide/topics/resources/providing-resources.html
Assets are raw resources, they won't be compressed by the android compiler.
From the developers site:
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 the AssetManager. For example, this is a good location
for textures and game data.
The assets/ folder in apk is intended to store any extra user files in any formats. They will be included to apk automatically on compilation stage and can be accessed from the app using getAssets() function.
I am developping an Android application with Eclipse.
I have chosen to store data of my application in an XML file in internal storage.
For debugging pupose, I would like to populate this data file by hand and to deploy it in internal storage on the device.
Is there a custom folder of my projet from which files will be copied in "internal storage" location when deploying / testing the app ?
You could probably use the /assets folder of your project.
http://developer.android.com/guide/developing/projects/index.html :
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 the AssetManager. For example, this is a good location for textures and game data.
you can upload the files to the emulator using DDMS. Try this link
I am analyzing an APK, and see a set of .txt resources in the /res/raw/ directory of the application. After installing the application on an emulator, I would expect to see those same files in the /data/data/[app]/files directory, but they do not seem to exist. Where are the raw resources stored? Are raw resources generated at application runtime somewhere else on the filesystem? Or when they are accessed, is it dynamically from the local .apk file? Thanks.
Raw resources (and really, all resources) are bundled in the APK file (this includes files placed in assets/), which is why you cannot get to the using File handles. The APK files themselves usually live in the system/app directory of the device.
The internal storage location you mentioned (/data/data/[app]/files) is where files created with Context.openFileInput(), Context.openFileOutput(), or Context.getFilesDir() are placed.
HTH