0
votes

I am using Flash Builder 4.6 to develop an Android game using Air. When I debug on PC it works fine, however when I plug in my Android phone and attempt to debug, I get an error with the location of a db file.

This is what I presently have the location set to:

private static var DefaultDB:File = File.applicationDirectory.resolvePath("com/arakaron/Assets/Database/DefaultDb.db");

What / where should I be setting it to? It seems that when I debug the app, nothing gets transferred to the phone as I can't find any Arakaron resources on the phone.

Any help would be great.

Thanks.

2

2 Answers

0
votes

You can't access the DB in this way.

Please use below code. File.applicationStorageDirectory.resolvePath("DefaultDb.db");

Your db has to be within the application storage. If you want to have inside the folder then you define the folder name like below: File.applicationStorageDirectory.resolvePath("db\DefaultDb.db");

0
votes

The File.applicationDirectory on Android refers to your application and assets. On Android this is contained packaged in your APK and assets are decompressed in memory by the OS when you access them. You shouldn't use this directory unless you are reading assets from your package. Assets in this directory can only be accessed via a url and won't have a nativePath property.

Most likely you should use the File.applicationStorageDirectory or if the files can be safely deleted without breaking the operation of your application you should use the File.cacheDirectory.

You can read more on these locations: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7fe4.html

If you package a database with your application you should use the File copy process to copy the file to one of the above locations before attempting to access it as a database.