Skip to main content
rjoshicool
Inspiring
July 5, 2011
Answered

Reading and writing SQLLite DB on iPhone

  • July 5, 2011
  • 3 replies
  • 4349 views

Hi,

I want to create an AIR for iOS application where a SQLLite DB will be written and read. The application works fine when tested in Flash Builder 4.5 but there are issues when testes on iPhone. I guess there is problem with the path where the DB is created. Any suggestions?

This topic has been closed for replies.
Correct answer blazejewicz

Hi,

is your .db shippped with application? If so how you're accessing it?

When creating .db file I think it's adviced to use documents directory "File.documentsDirectory.resolvePath(......)" not application directory (from user point there is no difference as all files are created in application filesystem sandbox).

hth,

regards,

Peter

3 replies

rjoshicool
Inspiring
July 8, 2011

Thanks all for the help. I was able to figure out that YES, Sqlite works on iOS devices. Updating it late, but I successfully created and read a Sqlite file on iPad. Though there are issues with which diretory to use for storing it, when I tried with the documentsDirectory, it worked well.

Participant
July 7, 2011

Sadly it is no possible at the moment to use an database on the iPhone.

You'll have the used SharedObject instead if you want to save data on the iphone.

For more info: http://www.adobe.com/devnet/flash/articles/saving_state_air_apps.html

Participating Frequently
July 7, 2011

Hi Johan,

what makes you think about SQLite support missing on iPhone? (this could mislead people). It should be supported I think (I've read passage about data support when iOS support was added on devnet somewhere) - though Adobe docs are lacking bits of exact information sometimes (or more often).

I've no valid developer cert right now so can't do test on iPhone - but I believe Sanika is from Adobe so lets' believe her statements.

regards,

Peter

Participant
July 8, 2011

Well, of course you have SQL lite support while coding native object C.

But this question was posted in the Adobe AIR Forum, I think that allows me to safely assume the poster is using Adobe ActionScript with or without the Flex framework to write his or her program.

blazejewiczCorrect answer
Participating Frequently
July 5, 2011

Hi,

is your .db shippped with application? If so how you're accessing it?

When creating .db file I think it's adviced to use documents directory "File.documentsDirectory.resolvePath(......)" not application directory (from user point there is no difference as all files are created in application filesystem sandbox).

hth,

regards,

Peter

rjoshicool
Inspiring
July 5, 2011

No, the .db is not shipped with it. It is created once the application starts running. Will File.documentsDirectory work on iPhone also?

Community Manager
July 7, 2011

Where are you creating the db. For your application to be able to access it, use documentsDirectory. It is resolved to /var/mobile/Applications/<appID>/Documents/.

Thanks,

Sanika