sql - Android, Ormlite, DB location -



sql - Android, Ormlite, DB location -

i'm using ormlite persist of info android app (running on motorola xoom). default, sql database saved /data/data/[package name]/databases/[dbname].db. problem is, xoom not rooted , hence users not have access directory db saved (can't copy/backup/edit content of db).

i have added code 1 of classes re-create db /data sd card, works fine, realistically think should possible set path db stored. missing something, or not possible ormlite?

thanks in advance, c

you can create database on sdcard if utilize like

public class databasehelper extends ormlitesqliteopenhelper { [...] public databasehelper(final context context) { super(context, environment.getexternalstoragedirectory().getabsolutepath() + file.separator + database_name, null, database_version); }

this creates db file in e.g. /mnt/sdcard/android/data/com.your.app/files/mydata.sqlite pro: saves internal memory con: db not accessible when sdcard not available (e.g. when connected pc) also, can read pro or con.

using context.getexternalfilesdir() instead of environment.getexternalstoragedirectory() utilize location specific app , cleaned automatically after uninstall (and appears on 2.2 on app update).

p.s. read somewhere approach might not work on android versions prior 2.2(?)

android sql ormlite

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -