Tag: sqlite

ORMLite query for date

I am trying to query for a date between low and hign value: Car car = new Car(1, “octavia”); car.setManufactured(Calendar.getInstance().getTime()); Dao<Car, Integer> carDao = getHelper().getCarDao(); carDao.create(car); QueryBuilder<Car, Integer> carQb = carDao.queryBuilder(); Calendar yesteday = Calendar.getInstance(); yesteday.add(Calendar.DATE, -1); Calendar tommorrow = Calendar.getInstance(); yesteday.add(Calendar.DATE, 1); carQb.where().between(“manufactured”, yesteday.getTime(), tommorrow.getTime()); PreparedQuery<Car> query = carQb.prepare(); List<Car> cars = carDao.query(query); Log.d(TAG, […]

SQLiteException: near “” :syntax error (code 1) while compiling

I have this error while compiling and I donĀ“t know why, can anyone help me? public static final String TABLE_BEERS = “cervezas”; // Contacts Table Columns names public static final String KEY_NAME = “_id”; public static final String KEY_COMPANY = “company”; public static final String KEY_TYPE = “type”; public static final String KEY_ALCOHOL = “alcohol”; […]

Android application and myBatis

I’d like to use myBatis (iBatis 3) in an Android application. Has anyone tried such a thing or know of any resources for this?

Android sqlLite ON CONFLICT IGNORE is ignored in ICS

I have a simple address table with the following create statement: “CREATE TABLE ” + ADDRESSES_TABLE + ” (” + KEY_ADDRESS_ID + ” INTEGER PRIMARY KEY AUTOINCREMENT, ” + KEY_ADDRESS_COUNTRY + ” TEXT, ” + KEY_ADDRESS_CITY + ” TEXT, ” + KEY_ADDRESS_STREET + ” TEXT, ” + KEY_ADDRESS_HOUSE + ” TEXT, ” + KEY_ADDRESS_POSTAL_CODE + […]

Will cursor be still alive after database is closed?

My code is like below: Cursor getResults() { SQLiteDatabase db = dbHelper.getReadableDatabase(); Cursor c = qb.query(db, projection, null, null, null, null, null); db.close(); return c; } My question is, after db.close() is executed, is the cursor c still alive and navigable? Thanks.

Data Types used in SQLite

I’m confused what to declare as datatype in SQLite for the following: 1.email 2.phone number 3.password(Some articles I find that they use String instead of int for phone number and password , why is it so?)

How to print query executed by query() method of android

We pass so many parameters to query() method of android. Android has simplified our work by giving query method. Is there any way so that i can print the sql query which android will form from this query method arguments which android creates and sends to sqlite.

Creating data model class for database handling

I was just starting to work on an database application when I realized I should implement MVC pattern as the application is quite complex and involves a number of database operations. In regards to this, I have decided to create a separate model class for handling database operations. This class will have all methods which […]

How to store and retrieve a byte array (image data) to and from a SQLite database?

How do I store and retrieve a byte array (image data) to and from a SQLite database in Android?

How to use my own sqlite database?

I put my database field in “assets” folder. And use the code from this blog to copy the database to “/data/data/my_packname/databases/”, (This copy code i run it in the onCreate() method when i run this app) then use select * from … to get data. But it gives me the exception: no such table. Someone […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.