I know it's been asked many times in stackoverflow. Those posts have answers too, but none of them works for me.
I have a database file mydb.sqlite placed it on assets folder. But it fails on the .openDatabase line. What am I doing wrong? In other posts I see that the dbpath pointing to /data/data, but I'm having hard time finding that path in my project.
This is my very first android app. I have been an iphone developer for few years now.
Error: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
try {
SQLiteDatabase db = SQLiteDatabase.openDatabase("/android_asset/mydb.sqlite", null, SQLiteDatabase.NO_LOCALIZED_COLLATORS|SQLiteDatabase.OPEN_READONLY);
Cursor cursor = db.rawQuery("SELECT * FROM mytable", null);
cursor.moveToFirst();
} catch (Exception e) {
e.printStackTrace();
}
Aucun commentaire:
Enregistrer un commentaire