Tag: sqlite

Debugging sqlite database on the device

I am presently working on an WiFi application for Android. I am having trouble trying to access the database on the device. Debugging in the emulator doesn’t work for me, because there is no WiFi support in the emulator. I tried pulling the database file out of the device by using adb pull data/data/package-name/databases/database-name But […]

How do I use prepared statements in SQlite in Android?

How do I use prepared statements in SQlite in Android?

SQLite Query in Android to count rows

I’m trying to create a simple Login form, where I compare the login id and password entered at the login screen with that stored in the database. I’m using the following query: final String DATABASE_COMPARE = “select count(*) from users where uname=” + loginname + “and pwd=” + loginpass + “);” ; The issue is, […]

Android SQLite DB When to Close

I am working with a SQLite database on android. My database manager is a singleton and right now opens a connection to the database when it is initialized. It is safe to leave the database open the entire time so that when someone calls my class to work with the database it is already open? […]

Android SQLite database: slow insertion

I need to parse a fairly large XML file (varying between about a hundred kilobytes and several hundred kilobytes), which I’m doing using Xml#parse(String, ContentHandler). I’m currently testing this with a 152KB file. During parsing, I also insert the data in an SQLite database using calls similar to the following: getWritableDatabase().insert(TABLE_NAME, “_id”, values). All of […]

Is there type Long in SQLite?

I want to create a table with the column type Long instead of Integer. Is it possible?

How do I join two SQLite tables in my Android application?

Background I have an Android project that has a database with two tables: tbl_question and tbl_alternative. To populate the views with questions and alternatives I am using cursors. There are no problems in getting the data I need until I try to join the two tables. Tbl_question ————- _id question categoryid Tbl_alternative ————— _id questionid […]

Foreign key constraints in Android using SQLite? on Delete cascade

I have two tables: tracks and waypoints, a track can have many waypoints, but a waypoint is assigned to only 1 track. In the way points table I have a column called “trackidfk” which inserts the track_ID once a track is made, however I have not setup Foreign Key constraints on this column. When I […]

IN clause and placeholders

I’m attempting to do the following SQL query within Android: String names = “‘name1’, ‘name2”; // in the code this is dynamically generated String query = “SELECT * FROM table WHERE name IN (?)”; Cursor cursor = mDb.rawQuery(query, new String[]{names}); However, Android does not replace the question mark with the correct values. I could do […]

SQLite in Android How to update a specific row

I’ve been trying to update a specific row for a while now, and it seems that there are two ways to do this. From what I’ve read and tried, you can just use the: execSQL(String sql) method or the: update(String table, ContentValues values, String whereClause, String[] whereArgs) method. (Let me know if this is incorrect […]

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