Tag: sqlite

SQLite auto increment not working

ok this isn’t spamming and it’s supposed to be simple I don’t know why it’s not working this is my code: gamesdatabase = openOrCreateDatabase(“GamesDatabase”, MODE_PRIVATE, null); gamesdatabase.execSQL(“CREATE TABLE IF NOT EXISTS Games (ID INTEGER PRIMARY KEY, Name VARACHAR, NPlayers INT(1), NRounds INT(2), WinScore INT(2));”); gamesdatabase.execSQL(“INSERT INTO Games (ID, Name, NPlayers, NRounds, WinScore ) VALUES ( […]

How to convert milliseconds to date in SQLite

I store date from Calendar.getTimeInMilliseconds() in SQLite DB. I need to mark first rows by every month in SELECT statement, so I need convert time in milliseconds into any date format using SQLite function only. How can I avoid this?

Delete all rows from a table, throws nullpointer

I’m trying to write a function that will delete every row in a given table but I’m getting a null pointer exception. Could somebody point me in the right direction? Here is the code… public void deleteall(){ SQLiteDatabase db = tweets.getWritableDatabase(); String delete = “TRUNCATE FROM tweets”; db.rawQuery(delete, null); }

Need to show a SQLite query in descending order

I want to make a query such that the result will be shown in indistinct descending order. For example, assume column ID has six rows. I need an query that shows me the list of IDs indistinct descending from 6 to 1. EDIT: Based on the first post’s text, the question is how do display […]

Sqlite Delete Query syntax in Android

I want to write a Query to delete a row from the table. I am confused of writing the statement. I need some help in writing this. I am providing my requirement here with plain sql statement. (Pseudo code) delete from tablename where value ==”string1″ && value2 == “string2” && value3 == “string3”; I want […]

Android SQLiteException: Failed to change locale for db to 'en_US'

I recently updated one of my (open-source) Android apps and my users are getting an exception that I can’t replicate. The key parts are : android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5) and then Caused by: android.database.sqlite.SQLiteException: Failed to change locale for db ‘/data/data/com.airlocksoftware.hackernews/databases/hacker_news_cache.db’ to ‘en_US’. This is happening on devices with Android 2.3 – 4.2.1, […]

Using swagger with an android database

I’m looking for away to use Swagger with an on-device database on android, ideally with GreenDAO and retrofit but I’m willing to use what works. The app will need to have a persistent database and also sync/communicate with a server that uses swagger. I’m looking for ways to use the code generation of swagger with […]

android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed even after closing cursor

There are many questions on SO about CursorWindowAllocatoinException: SQLite Android Database Cursor window allocation of 2048 kb failed Could not allocate CursorWindow Out of Memory when allocating cursors Android SQLite CursorWindowAllocationException crash All of them suggest that cursor must be closed after use. But that did not resolve my problem. Here is my code: String […]

Android One Plus Two: Failed to change locale for db

I am using Sqlite database in one of my Android project. It works fine in all the devices except One Plus Two device. I am getting exception while trying to open the database. This is the crashlog. 12-23 19:14:35.235: E/SQLiteLog(3133): (11) database corruption at line 53216 of [9491ba7d73] 12-23 19:14:35.235: E/SQLiteLog(3133): (11) statement aborts at […]

Android: sqlite: cursor: getColumnIndex

I’ve got a fairly complicated query (multiple joins) on a normalized sqlite database. The query does a SELECT * to enable some automated attribute selection logic (so I can’t eliminate the “*”) The problem I am having is that my result set contains multiple columns with the same attribute name. For example, one attribute common […]

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