android sqlite - ActiveAndroid - no fields are created

I just tried to use ActiveAndroid. Following their tutorial from here, I set everything.I added the manifest entry: application android:name="com.activeandroid.app.Application" ...meta-data android:name="AA_DB_NAME" android:value="MyDb.db"meta-data android:name="AA_DB_VERSION" android:value="1"and created my model class:package com.mycomp.Model;import org.joda.time.LocalDate;import org.odata4j.core.Guid;import com.activeandroid.Model;import com.activeandroid.annotation.Column;import com.activeandroid.annotation.Table;@Table(name = "Table1")pub...Read more

android sqlite - Using pre-populated database in Room by copy database file from assert

I want to use pre-populated database in Android Room. I found a way to make it through using the callback, and filled up the database files.But something is wrong, I'm sure that the database is copied normally, but it remains empty in the device monitor and android emulator. Can you please help mepublic abstract class AppDatabase extends RoomDatabase {private static AppDatabase INSTANCE;private static final String DB_NAME = "base.db";static Context ctx;public abstract Dao dao();public static AppDatabase getDatabase(Context context) { if (INS...Read more

app update - SQLite tables lost when my app is updated though I'm not dropping it in onUpgrade()

I have a version of my app currently in production. I have switched from windows PC to Mac recently. Now when I release an updated APK from my Mac, the sqlite database is lost on updating the app. Even the table which I'm not dropping through code for sure, is being dropped. And it didn't even get created when I included a create if not exists... query. Should something other than the source code be affecting this (like the underlying android SDK or the JDK)? I never enabled proguard in any of my app releases. FYI, the issue doesn't occur when ...Read more

How to use images in Android SQLite that are larger than the limitations of a CursorWindow?

As per the question. Say I have an Image that is approx 3.5 MB in size, which could be saved as a blob, but couldn't be retrieved due to the 2Mb limitation of a CursorWindow?NoteThe question has been asked purely to show, contrary to responses saying that it cannot be done, that it can be done (albeit NOT RECOMMENDED), as this is a It’s OK to Ask and Answer Your Own Questions....Read more

fts4 - "optimize" command in sqlite fts3 on android makes "MATCH" doesn't work

I am creating a fts4 table in android , I batch insert large number of rows then optimize as recommended in sqlite documentationI use the following code in android public void indexFts() { SQLiteDatabase db = getWritableDatabase(); db.execSQL("CREATE VIRTUAL TABLE IF NOT EXISTS pageTextSearch USING fts4(content=\"\", page)"); db.beginTransaction(); try { SQLiteStatement populateFTS_Statement = db.compileStatement(INSERT INTO pageTextSearch(docid,page)VALUES (?, ?)); //pre-compiled sql statement while (all...Read more

Are there any methods that assist with resolving common SQLite issues?

It is often that relatively simple errors cause issues often compounded by a misunderstanding of SQLite. For example:-tables and columns not found because it is often assumed that the onCreate method of a DBHelper (subclass of the SQLiteOpenHelper class) runs every time an instance of the DBHelper is created or every time the App is run. (Note! onCreate is only automatically invoked when a Database is first created and then only when an attempt is made to use one of the SQLiteDatabase getReadableDatabase or getWriteableDatabse methods, if chang...Read more

How flexible/restricive are SQLite column types?

Recently there has been some debate regarding the flexibility of column types in SQLite. Hence the question, How flexible are SQLite column types?One argument was that types are restricted to the the main five, namely, TEXT, NUMERIC, INTEGER, REAL and BLOB, and additionally the named column types in the official documentation i.e. :- INT, TINYINT, SMALLINT, MEDIUMINT, BIGINT, UNSIGNED BIG INT, INT2, INT8, CHARACTER(20), VARCHAR(255), VARYING CHARACTER(255), NCHAR(55), NATIVE CHARACTER(70), NVARCHAR(100), CLOB, no datatype specified (BLOB), D...Read more

How to query SQLite by integer?

I have a SQL table like the following:ID(string) Name(string) Width(double) Height(double) Selected(int)12345678 Book 210 297 112345679 Display 530 326 012345680 Phone 70 140 0I can query them by ID and Name by passing a String argument without issue, but all int and double queries return null. Why?This is the code I tried:Cursor cursor = mDatabase.query( "Objects",null, "Selected" + " = ?", new String[]{String.valu...Read more

Android Room subquery in FROM clause not working as expected

I tested my query using https://sqliteonline.com/ but cannot get it to work with Android Room and I cannot understand why (believe me I've tried). Why is the query in my DAO not working? On the other hand, I'm not sure this is the best way to achieve what I'm trying to do so please do tell me if I should change my approach completely.Also, it's my first time posting a question, I apologize if I'm omitting something important.I made a test database with sqliteonline and verified my query is working there. I'm using Android Room in my project, wi...Read more

android sqlite - net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master

Error this line : mDataBase = SQLiteDatabase.openDatabase(dbPath, "123", null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);When open the database . but whats Wrong? how to open database with password? Can any one help me?I set the password on SQLITE Db Browser > File> Set encryption open this password in android part When Open then show error error : net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_masterCan any one help me to solve it? thanks in advance import android.content.Context;im...Read more

android sqlite - Room database handling inheritance in POJO and multiple tables

I have an issue while migrating from sqlite to Room. I have 1 parent and 1 child class and 2 tables corresponding to it. I have inheritance as follows public class Sms { int _id; String sender; String body; Date date;} public class Event extends Sms { String eventName; long eventDueDate;}And I have tables as SmsTable >> _id INTEGER NOT NULL primary key autoincrement,sender TEXT not null,body TEXT not null,date INTEGER not nullEventTable >>_id INTEGER NOT NULL primary key autoincrement,sms_id INTEGER,eventName TEXT...Read more

How to set primary key in SQLite database after the table have been already created?

How to set primary key in SQLite after table have been already created?I am creating a project using SQLite and I have forgetton to provide the primary key to user id,now how can I set it?Below is my ContactContract classpublic final class ContactContract { private ContactContract(){} public static class ContactEntry { public static final String TABLE_NAME="contact_info"; public static final String KEY_P = "KEY"; public static final String CONTACT_ID = "contact_id"; public static final String NAME="name"; ...Read more

how to delete the data from sqlite populated in lisview

I am using sqlite and there is a problem while delete data from sqlite which is populated in listview.There is no error in logcat. Id of selected item is toast.But can't delete the data from database.if i delete each row one by one then data is not found there but when i add some new data after that deleted data is also there.when i click the button named viewinfo last entry is repeated in listview.this is the code to delete data from sqlite which is stored in listview public Integer deleteData(String position){ SQLiteDatabase db=getWrit...Read more