Markus wrote:
> I want to create a database that may become relatively large, a few
> megabytes maybe. maybe I should put this database on the sd card to
> save internal storage.
> 
> With SQLiteDatabase.openOrCreateDatabase() this should be quite
> straightforward.
> 
> But I'd like to use SQLiteOpenHelper since it takes care of creating
> and updating the db so nicely. Unfortunately SQLiteOpenHelper seems to
> be restricted to the internal storage.
> 
> Now I have noticed that SQLiteOpenHelper uses
> Context.openOrCreateDatabase() and Context.getDatabasePath()
> internally.

For some reason, getReadableDatabase() uses getDatabasePath(), but
getWriteableDatabase() does not. That seems...odd.

> Would it be too much of a dirty hack if I wrote my own ContextWrapper
> that implements these methods to create a database on the sd card? Or
> would this be a legitimate use of the API?

That might work, but then if they change the implementation of
SQLiteOpenHelper, you might not realize that you also need to change
your ContextWrapper somehow to match.

Since SQLiteOpenHelper is not that big and is only directly used by your
app, another approach is to grab their code, modify it to create an
SDOpenHelper that supports your database-on-SD model, and use that.
Assuming SQLiteOpenHelper is not using any package-private methods, of
course...

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 1.0 Available!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to