Skip to main content
August 4, 2011
Question

Where can I store app content?

  • August 4, 2011
  • 2 replies
  • 644 views

We're transitioning our AIR apps to Android and am a little unsure of a few things.

We're busy developing a magazine type app that will have content (images, video, swfs) downloaded by the app to the tablet device over time and will grow as new issues appear. The app will also use an AIR SQLite db.

1. Where should this content live? I've considered putting it on an SD card, but some tablets don't have external storage. Best practice suggests that this kind of data shouldn't be stored in the File.applicationStorageDirectory so I'm guessing somewhere else on the filesystem. If anybody can point me to a similar post or discussion around this I can then clarify my understanding of this.

2. When the app gets updated (if I understand correctly, essentially by a brand new .apk file), I'm assuming all the app data and related SQLite db's get deleted? If so, how do I update the app but maintain the database? This is also the crux of my forum question of where I should place the app content.

Any pointers, links and hints to this will be very much appreciated! And of course, my terminology may be incorrect so feel free to correct.

Thanks

Simon

This topic has been closed for replies.

2 replies

August 5, 2011

Thanks Anurag.

Together with your response and other searching I think I understand the situation better.

What confused me was the concept of external storage, as this was where Android saves File.documentsDirectory data too.

On the Galaxy 10.1, it doesn't have any physical external storage ie. no place to insert an SD card. Yet there is a reference to it in the file manager.

(Seriously confused face).

It turns out that 'external storage' is somewhat of a misnomer, as it can be physically internal and external:


"The entire /sdcard directory (with the DCIM, Android, Samsung folders) is your internal SD card.


/sdcard/sd is your external SD card. When there is an external SD, you will see the little card symbol in the icon from "My Files". If there is no external SD, or if it is unmounted, then you will not see the little card symbol and the directory /sdcard/sd is just a placeholder. Any files you put in there will be gone once you mount an external SD." androidforums.com

Ah!

I also found this forum post which helped develop my understanding further about persistence of data.

And Frédéric, my guess is that one could 'share' documents across apps in this way, if the permissions are correct. Two posts I found deal with that - about Android and about iOS - might be relevant.

Participating Frequently
August 4, 2011

You can actually store the database file in

File.documentsDirectory

Its help description is like:

On Windows, this is the My Documents directory (for example, C:\Documents and  Settings\userName\My Documents). On Mac OS, the default location is  /Users/userName/Documents. On Linux, the default location is  /home/userName/Documents (on an English system), and the property observes the  xdg-user-dirs setting.

The documentsDirectory property provides a way to reference the  documents directory that works across platforms. If you set a File object to  reference the documents directory using the nativePath or  url property, it will only work on the platform for which that path  is valid.

If an operating system does not support a documents directory, a suitable  directory in the file system is used instead.

Hence you can use it as whenever you uninstall your application the database file will be persisted.

It works fine as I am using in my application.

Frédéric C.
Inspiring
August 5, 2011


Thanks for the info! Does that mean that you can share documents across several applications on iOS?

Is the File.documentsDirectory a common place that can be accessed by various apps? I'd need to share a saved game across several volumes of an adventure game, and was wondering if it could do the trick.