Question
I'm developing a native Tizen application that needs to load and potentially modify some files during runtime. I placed these files in the /data/ folder since the /res/ folder is read-only.
However, when I package the project into a .tpk file, the /data/ folder isn't included. This causes the application to fail after installation because it can't load the required files at startup. How can I ensure these data files are included in the package?
Answer
Problem Understanding
The issue occurs because Tizen's build system doesn't automatically include files in the /data/ directory when creating the .tpk package. This is different from the /res/ directory which is included by default but is read-only.
Solution Methods
-
Using the shared/resource directory:
- Move your files to the shared/resource directory in your project
- These files will be included in the package automatically
- Access them using app_get_shared_resource_path() at runtime
-
Manually including files in package:
- Create a "data" directory in your project root
- Add the files you want to include
- Modify your project's manifest file (tizen-manifest.xml) to include these files:
<tizen:application> ... <tizen:file path="data/myfile.txt" /> </tizen:application>
-
Alternative approach for writable files:
- Include initial files in the package using method 1 or 2
- At first run, copy them to the app's data directory (obtained via app_get_data_path())
- Modify the copies as needed during runtime
Code Examples
// For shared resources
char* resource_path = app_get_shared_resource_path();
// Use resource_path to access your files
// For app data directory
char* data_path = app_get_data_path();
// Use data_path for writable files
Additional Tips
- Remember that files in /res/ are read-only
- Files in the data directory (from app_get_data_path()) are writable but not included in the package
- Always check file operations for success/failure
- Consider file permissions when accessing files