-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yayo wrote:
[...]
> Is it possible to bundle a read/only dblite file with data for the
> application?

By 'dblite file' you mean a SQLite database file, right?

The short answer is: sort of.

The longer answer is:

SQLite can only open *files*. (i.e. something on the filesystem.) While
you can ship files in your apk in the form of raw resources, they don't
actually appear as files, and so you then can't open them from SQLite.
(Context.openRawResource() will only return you an InputStream, but
SQLiteDatabase.open() wants a path or a file.)

So you could ship a SQLite database in your apk, but you'd have to copy
it out of the apk and into you app's file storage area before you could
use it.

In fact, if you were going this route it would probably be more sensible
to ship an SQL dump rather than a raw database --- Android stores some
magic data in its databases which you'd have to replicate, and using an
SQL dump generally makes life easier. Unfortunately, actually *running*
the SQL dump is needlessly hard on Android (Android will only let you
run one statement at a time), but it is quite manageable.

- --
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "People who think they know everything really annoy those of us who
│ know we don't." --- Bjarne Stroustrup
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFKueJPf9E0noFvlzgRAthhAKDX60/Ncgjmpuk0tDxiH8hkok180wCeK/Hp
vBSptf70F+Qw3FkDhkXh6xI=
=M5KP
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
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