This guide explains how to use Assets in your project.
What is Assets ?
Assets is a folder which is placed under the app project folder.
You can use this folder to directly access the files inside it. Instead of the “Resources” and “Images”, this folder can be reached by file operations such as read. Additionally, the Assets folder is available for each kind of device independently: You don’t need to use separate folders as you do in Resources.
The Database file can also be placed under Assets folder.
During runtime, Assets folder is a read-only folder.
While generating exporting packages, codes will be placed in Assets folder.
In order to change a file in Assets, it should be copied into data and then it can be changed.
By using the below command, you can reach to related directory(assets://) :
Using an icon with assets
First, let's place a ".png" file inside the Assets folder.
Now, let's create an image object and see how we can use "myicon.png" :
After you add this image object (myImage) to the related page, it will look like below :
Reading a txt file from assets
As a second example, let's see how you can read a file in the assets folder.
First, create a ".txt" file or you can use an existing one. Secondly, place this file into the assets folder as below :
Now, let's create a textButton object, and when pressed to textButton, it will run the read method :
Add this textButton object(myButton) to the related page. When you press myButton, it will look like below :
Reading an XML file from assets
As a last example, let's read an XML file from Assets folder.
Place an XML file in Assets folder as below :
Now, let's create a label and a textButton as below :
When pressed to textButton, XML will be read and written on the label :