android - Error while opening my database -
android - Error while opening my database -
whenever seek access database gives error. same code running in other apps. here code of database helper class...
public class localdatabasehelper extends sqliteopenhelper{ private static final string tag = "localdatabasehelper"; public string db_path = "data/data/com.cybergeniesolutions.scentsysquirrel/databases/"; private static string db_name = "local.db"; public static final string key_rowid = "_id"; public static final string perfume_id = "perfume_id"; public static final string got_it = "got_it"; public static final string name = "name"; public static final string phone = "phone"; public static final string website = "website"; public static final string facebook = "facebook"; public static final string rating = "rating"; public static final string my_choices ="my_choices"; public static final string ratings = "ratings"; public static final string consultant_details = "consultant_details"; private static final int database_version = 3; private static final string create_my_choices_table = "create table " + my_choices + " (" + key_rowid + " integer primary key autoincrement, " + perfume_id + " numeric, " + got_it + " text not null);"; private static final string create_ratings_table = "create table " + ratings + " (" + key_rowid + " integer primary key autoincrement, " + perfume_id + " numeric, " + rating + " numeric);"; private static final string create_consultant_table = "create table " + consultant_details + " (" + key_rowid + " integer primary key autoincrement, " + name + " text not null, " + website + " text not null, " + phone + " text not null, " + facebook + " text not null);"; public sqlitedatabase mdatabase; public localdatabasehelper(context context) { super(context, db_name, null, database_version); log.v(tag,"localdatabasehelper()"); boolean dbexist = checkdatabase(); if (dbexist) { } else { log.v(tag,"databasehelper() database doesn't exist"); this.getreadabledatabase(); } } private boolean checkdatabase() { boolean checkdb = false; seek { file dbfile = new file(db_path + db_name); checkdb = dbfile.exists(); } grab (sqliteexception e) { throw new error("database doesn't exist"); } homecoming checkdb; } public void open() { // open database mdatabase = sqlitedatabase.opendatabase(db_path + db_name, null, sqlitedatabase.open_readwrite); } public cursor getconsultantdetails() { log.v(tag,"inside getconsultantdetails()"); homecoming mdatabase.query(consultant_details, new string[] {name, phone,website,facebook}, null, null, null, null, null); } public void addconsultant(string name, string phone, string website, string facebook) { contentvalues initialvalues = new contentvalues(); initialvalues.put(name, name); initialvalues.put(phone, phone); initialvalues.put(website, website); initialvalues.put(facebook, facebook); mdatabase.insert(consultant_details, null, initialvalues); } @override public synchronized void close() { if(mdatabase != null) mdatabase.close(); super.close(); } @override public void oncreate(sqlitedatabase db) { db.execsql(create_consultant_table); db.execsql(create_ratings_table); db.execsql(create_my_choices_table); log.v(tag,"oncreate()"); } public string getdbname(){ homecoming db_name; } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { } }
and here error getting when phone call getconsultantdetails()
06-24 12:09:07.040: e/sqlitelog(952): (14) cannot open file @ line 30174 of [00bb9c9ce4] 06-24 12:09:07.040: e/sqlitelog(952): (14) os_unix.c:30174: (2) open(//data/data/com.cybergeniesolutions.scentsysquirrel/databases/local.db) - 06-24 12:09:07.080: e/sqlitedatabase(952): failed open database 'data/data/com.cybergeniesolutions.scentsysquirrel/databases/local.db'. 06-24 12:09:07.080: e/sqlitedatabase(952): android.database.sqlite.sqlitecantopendatabaseexception: unknown error (code 14): not open database 06-24 12:09:07.080: e/sqlitedatabase(952): @ android.database.sqlite.sqliteconnection.nativeopen(native method) 06-24 12:09:07.080: e/sqlitedatabase(952): @ android.database.sqlite.sqliteconnection.open(sqliteconnection.java:209) 06-24 12:09:07.080: e/sqlitedatabase(952): @ android.database.sqlite.sqliteconnection.open(sqliteconnection.java:193) 06-24 12:09:07.080: e/sqlitedatabase(952): @ android.database.sqlite.sqliteconnectionpool.openconnectionlocked(sqliteconnectionpool.java:463)
android database sqlite
Comments
Post a Comment