sqliteopenhelper

Why in a test class that extends AndroidTestCase, does getContext() return null?

只愿长相守 提交于 2019-12-10 19:28:27
问题 I have my own SQLiteOpenHelper as follow : public class MyOpenHelper extends SQLiteOpenHelper { public static final int DB_VERSION = 1; public static final String DB_NAME = "dbname"; public MyOpenHelper(Context context) { super(context, DB_NAME, null, DB_VERSION); } @Override public void onCreate(SQLiteDatabase sqLiteDatabase) { /* My create code */ } @Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) { /* My upgrade code */ } @Override public void

SQLiteCantOpenDatabaseException: unknown error (code 14) Could not open database

青春壹個敷衍的年華 提交于 2019-12-10 18:29:36
问题 I'm getting this error when I'm trying to get a readable or writable database. "SQLiteCantOpenDatabaseException: unknown error (code 14) Could not open database" I'm having this weird problem with SQLiteOpenHelper and I've seen some similars answer about this same issue here but none of them solved my problem. As desperate as I am, I'm posting my code below in hope some one find something I'm not seeing... (One important information: I get this app from another working one. But the very firt

Issue with SQLiteOpenHelper on android 2.X and 3.X

放肆的年华 提交于 2019-12-10 16:31:57
问题 So i made a big mistake of testing my code on android 4.0 + and thinking it would work fine on other versions. But i am facing issues with 2.X and 3.X with SQLiteOpenHelper. First the code : public class HelperDB extends SQLiteOpenHelper implements BaseColumns { public static final int DATABASE_VERSION = 2; public static final String DATABASE_NAME = "MYDB.db"; public static final String TABLE_NAME = "MYtable"; public static final String TABLE_NAME_LOGO = "MYLogos"; public static final String

error inserting android.database.sqlite.sqliteconstraintexception error code 19 constraint failed

匆匆过客 提交于 2019-12-10 16:26:12
问题 I know there are so lot of threads about this problem but none of my own problem. I have a spinner connected in the database that displaying the foreign key of the specific table. And it appears error inserting. 02-18 11:44:34.500: E/SQLiteDatabase(20811): Error inserting ConsumerName=android.database.sqlite.SQLiteCursor@4144fa58 kWh=801.0 _id=65324 Date=2013 -2-18 Previous=98 Current=899 02-18 11:44:34.500: E/SQLiteDatabase(20811): android.database.sqlite.SQLiteConstraintException: error

Android - Can't Find Table in Pre-made Database

送分小仙女□ 提交于 2019-12-10 12:23:51
问题 I am trying to make a program that will take an SQLite database I already made (called os.sqlite) and be able to read/write that database. I followed code from here and Eclipse gives me no errors in the process of copying the database, it seems, but when I try to run my application and display the table "OregonState," LogCat (I am using Eclipse Juno with the ADT plug-in and running my applications on the SDK emulator) keeps telling me that there is no table named "OregonState," which is a

Exception- Writing exception to parcel

纵饮孤独 提交于 2019-12-10 12:17:19
问题 This is a small assignment to insert simple text data to sqlite database. I have used SQLiteOpenHelper class for this and used given code. I've found some similiar questions here but not the exact same. Please help me out. Here is the exception- 11-14 21:59:17.786 5746-5763/? E/DatabaseUtils: Writing exception to parcel java.lang.SecurityException: Neither user 10169 nor current process has android.permission.READ_PROFILE. at android.app.ContextImpl.enforce(ContextImpl.java:1921) at android

Confused about CursorLoaders and using them with a custom SQLiteOpenHelper

你说的曾经没有我的故事 提交于 2019-12-10 04:29:06
问题 I'm writing an app that allows people to set alarms for various tasks that they need to do. My current plan is to store all the relevant data into an SQLite database. To that end, I have created a class that extends SQLiteOpenHelper and filled it with methods to handle all the CRUD that I'd expect to have to take in. Knowing that it's generally a bad idea to do all the processing on one thread, I looked up ways to separate the work between threads and found CursorLoader and LoaderManager,

DB File in Assets Folder. Will it be Updated?

↘锁芯ラ 提交于 2019-12-09 13:48:13
问题 I'm new to the Android SQLite whole thing. This is what I have: I have db.sqlite in my assets folder. The intent of the db is to READ ONLY. The user will not write to it. When the app gets updated, the db.sqlite will be replaced be a new db (I'll delete the old file from the project and add the new one). What I'm concerned about is: Will the old db file gets deleted? (that's what I want; replacing the old one with the new one) Why ask? Because when I debug my app, each time I update the db

SQLite database migration appears to only partially apply in Espresso test

夙愿已清 提交于 2019-12-08 21:14:02
问题 We have an SQLite database and a corresponding SQLiteOpenHelper subclass. This helper has an onDowngrade implementation that I would like to write an Espresso test for. The full onDowngrade implementation is available here. This is a simplified version of it: @Override public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("CREATE TABLE IF NOT EXISTS foo_tmp (_id integer primary key, bar text not null, baz text not null);"); db.execSQL("INSERT INTO foo_tmp(_id

SQLiteOpenHelper not calling onCreate

蓝咒 提交于 2019-12-07 20:26:42
问题 This is the fist time I've used SQLiteOpenHelper (or databases on android). When I get a writeable database I was wondering why onCreate isnt being called on each new instance of the class. Am I doing something wrong? public class DatabaseHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "MyDatabase.db"; private static final int DATABASE_VERSION = 1; private String PrSQLcmd = ""; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE