Saturday, 17 July 2010

getExternalFilesDir blues

Why getExternalFilesDir in Android 2.2 “Froyo” is not at all helpful. ...

With getExternalFilesDir Android 2.2 “Froyo” got yet another cool feature. At least the idea was good. Any Android user who installed a few applications which make use of the sd-card know the trouble: Every application created a directory on the sd-card some using the data type some the application name and even other the company name. As a result I have 5 directories for eBooks (Books, eBooks, iReader, Aldiko and WordPlayer).

Here comes getExternalFilesDir to put an end to all that. getExternalFilesDir has two operation modes: with type parameter and without.

With Type

If you specify a type then getExternalFilesDir will return a directory suitable for the given type. Nice, but with one drawback: The available file-types are pre-defined and can not be extended. There is also no definition for “other files”. The list is also not very extensive: The new hype eBooks are not included.

Without Type

Or an unknown type for that matter an application private directory is returned. Now here the Android developers has an even more genius idea: If the application is de-installed then the data is not needed any more as there is no need to keep them. And why bother the user with silly question — just delete them.

And while I usually all in favour of not asking the user silly question as well it just might be that the user wants to re-install or upgrade the application. There are lots of applications out there with demo, light adware versions which can be upgraded to a full or pro version.

That would put a lot of developers into the hot spot when using getExternalFilesDir. Would — all files are also deleted on update. For data which can be deleted on any bug fix you might as well use getExternalCacheDir.

2 comments:

  1. >
    After trying NOOK from B&N I have yet another eBook directory. What a pain.

    ReplyDelete
  2. >
    So it is a bug after all:

    http://groups.google.com/group/android-developers/browse_thread/thread/b68d40b1f13e12df/f3f37cc59d35617

    Scroll to the end. I wonder how long it will take until all devices are updated.

    ReplyDelete