Android: SQLite database not in internal memory -



Android: SQLite database not in internal memory -

i'm writing android application creates , populates sqlite database @ runtime. in similar apps, database gets automatically created in "/data/data//databases/" directory. however, isn't happening time. i've gotten "/data/data/" via adb shell, there no /databases/ directory, allow lone database in there. however, know database getting created , populated because print out first 10 entries check. else stored? have write_external_storage permission, , code gives no errors.

if helps, here database helper class (relevant parts):

public class databasehelper extends sqliteopenhelper { private static final int version = 1; private static int colnum; private static string dbname, tablename, filepath; private static string[] cols; private final context mycontext; public databasehelper(context context) { super(context, dbname, null, version); this.mycontext = context; } // creating tables @override public void oncreate(sqlitedatabase db) { filereader fr = null; seek { file dbfile = new file(filepath); fr = new filereader(dbfile); } grab (ioexception e) { e.printstacktrace(); } bufferedreader buffer; buffer = new bufferedreader(fr); string line = ""; string firstline; seek { firstline = buffer.readline(); cols = firstline.split(","); // name of columns header (first row of .csv) colnum = cols.length; // number of columns in each row of file } grab (ioexception e) { e.printstacktrace(); } string table_col = gettablecols(colnum, cols); db.execsql("drop table if exists " + tablename + ";"); string create = "create table " + tablename + table_col; db.execsql(create); populatedb(db, buffer, line); } public void populatedb(sqlitedatabase db, bufferedreader buffer, string line) { db.begintransaction(); seek { while ((line = buffer.readline()) != null) { string[] row = line.split(","); contentvalues cv = new contentvalues(); (int = 0; < colnum; i++) { cv.put(cols[i], row[i].trim()); } db.insert(tablename, null, cv); } } grab (ioexception e) { e.printstacktrace(); } db.settransactionsuccessful(); db.endtransaction(); } public string gettablecols(integer num, string[] cols) { string table_col = "("; (int = 0; < (num - 1); i++) { table_col += (cols[i] + " text, "); } table_col += cols[num - 1] + " text)"; homecoming table_col; } // upgrading database @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { //drop older table if existed db.execsql("drop table if exists " + tablename + ";"); //create tables 1 time again oncreate(db); } }

the database created in databases under application-specific info directory. on many not firmwares info directory /data/data/your.package.name databases location /data/data/your.package.name/databases/.

the application info directory protected filesystem permissions. cannot access unless have root or you're running package's uid.

android database sqlite memory

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -