Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 80
Registered: ‎03-17-2011
My Device: Playbook Tablet
My Carrier: -
Accepted Solution

Database permissions

[ Edited ]

Hi, I've written an application that runs fine on Flash builder, but won't save anything (to a sqlLite database) on the simulator. I think it's something to do with access permissions, but I'm not really sure which permission to use.

 

I tried adding <permission>access_shared</permission> to my blackberry-tablet.xml, but it didn't really seem to make a difference.

 

Right now, I can only read things from the DB, but can't save anything. It doesn't error, but doesn't save anything either.

 

Could anyone help me with this?

 

Thanks in advance,

Marcos Placona
www.placona.co.uk
My Playbook Apps:
Bonjour | Time Traveller | Magic Ball
Trusted Contributor
Posts: 152
Registered: ‎02-23-2011
My Device: dev alpha playbook 9500 8300
My Carrier: uc

Re: Database permissions

Avoid to use "access_shared" if your sqlLite database isn' t shared with other app.

try this:

use File.applicationStorageDirectory ,not the File.applicationDirectory , to create and wirte the dabase file ,
because the applicationDirectory is readonly.
Developer
Posts: 80
Registered: ‎03-17-2011
My Device: Playbook Tablet
My Carrier: -

Re: Database permissions

 


bdaemon wrote:
Avoid to use "access_shared" if your sqlLite database isn' t shared with other app.

try this:

use File.applicationStorageDirectory ,not the File.applicationDirectory , to create and wirte the dabase file ,
because the applicationDirectory is readonly.

 

That seems to be the way to go, however, I now keep getting the following:

 

SQLError: 'Error #3125: Unable to open the database file.', details:'Connection closed.', operation:'open', detailID:'1001'.

 

Which suggests the file doesn't exist, however, when using applicationDirectory with the same path, it works.

 

Any other suggestions?

 

Cheers

Marcos Placona
www.placona.co.uk
My Playbook Apps:
Bonjour | Time Traveller | Magic Ball
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Database permissions

You can't modify files that are in the applicationDirectory, so if you need to make changes, your app has to first copy it to the applicationStorageDirectory (maybe the first time it runs, or whenever it can't find it there). After that it should work okay if you've used the right path etc.

There should be other threads you can find by searching that tell you more about copying files between those folders, if you don't know how. Also look at the copy routines in the File class, and find examples of that on the web.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Database permissions

when u do the connection.open() it should create the database file for you even if it doesnt exist. also as the others have stated as long you stay in your apps storage directory u dont need any extra permissions.
J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Highlighted
Developer
Posts: 80
Registered: ‎03-17-2011
My Device: Playbook Tablet
My Carrier: -

Re: Database permissions

[ Edited ]

Just solved it by doing:

 

 

// Init database
var embededSessionDB:File = File.applicationDirectory.resolvePath("assets/db.sqlite");
var writeSessionDB:File = File.applicationStorageDirectory.resolvePath("assets/db.sqlite");
 			
// If a writable DB doesn't exist, we then copy it into the app folder so it's writteable
if (!writeSessionDB.exists) {
	embededSessionDB.copyTo(writeSessionDB);
}
			
var dbFile:File = writeSessionDB;
	
dbConnection.open(dbFile);

 Thanks all for the responses

 

Marcos Placona
www.placona.co.uk
My Playbook Apps:
Bonjour | Time Traveller | Magic Ball