DB file in sdcard ?

741 views
Skip to first unread message

hadi

unread,
Oct 22, 2010, 6:15:23 AM10/22/10
to ORMLite Users
is there anyway i can use ormlite to create db file in sdcard ?

Gray Watson

unread,
Oct 22, 2010, 7:47:49 AM10/22/10
to ormlit...@googlegroups.com
On Oct 22, 2010, at 6:15 AM, hadi wrote:

> is there anyway i can use ormlite to create db file in sdcard ?

Are you asking if there is a way ORMLite can create a database that can be stored to a SD card?

If so then I guess the answer is sure. You could use SQLite and then copy the database files over to the SD card when you are done. As far as I know, SD cards do not support a huge number of write operations so you would not want to perform all operations on the SD card but rather do it in memory or in temporary disk space and then copy the database to the SD card as one write operation.

Take a look at this URL about how to save from memory to disk in SQLite: http://www.sqlite.org/backup.html

gray

Kevin Galligan

unread,
Oct 22, 2010, 10:15:26 AM10/22/10
to ormlit...@googlegroups.com

if you use the standard database helper, I'm not sure. Generally you just give it a name, and the db is added in the local db directory. You MAY be able to specify an absolute path to the sdcard. Like /sdcard/mydb

Had I to bet, that won't work, but you can try. If you just want a copy, you can copy the db file. Something like

/data/data/com.yourpackage/databases/dbname.db

Also, to get the SD card path, use Environment.get(forgot the name)

On Oct 22, 2010 6:47 AM, "Gray Watson" <256.com@gmail.com> wrote:

On Oct 22, 2010, at 6:15 AM, hadi wrote:

> is there anyway i can use ormlite to create db file in s...

hadi

unread,
Oct 22, 2010, 11:05:56 AM10/22/10
to ORMLite Users
i was thinking about doing a crud operation on db file which is
located in sdcard, not just file copy/backup to sdcard.

afaik, i can do this with
android.database.sqlite.SQLiteDatabase.openOrCreateDatabase("/sdcard/
test.db", null);
are there any reason why this can't be done by ormlite ?

anyway, i've tried using file path through ormlite database helper,
and you win your bet.. :)

Reply all
Reply to author
Forward
0 new messages