Tag: sqlite

Concurrent writing to android database (from multiple services)?

I’ve a serious problem with android sqlite database and concurrent writing. For better explanations, I will give you a real life example: I’ve an desktop widget, where I’m showing a list of items from my database (and on background I have DataService, which in regular intervals collects fresh data from my remote server, and update […]

How to retrieve data from sqlite database in android and display it in TextView

I am learning Android. I have a problem and I can’t solve it. I want to retrieve data from an existing database and display it in a TextView after click button. My code DataBaseHelper looks like this: public class DataBaseHelper extends SQLiteOpenHelper { //The Android’s default system path of your application database. private static String […]

Getting Strings from A Cursor in Android?

My cose is SIMPLE. I have a SQLite-Database with three columns: rowid title => text content => text This is a method in my dataBase-class: public Cursor fetchMessage(String tableNane, int id) { return myDataBase.rawQuery(“SELECT rowid as _id, title FROM “+tableName +” WHERE rowid = “+id, null); } This method will return only one row. In […]

What is the advantage of Using SQLite rather than File?

In Android, entering data in SQLite uses more time and more lines of codes than in .txt file. Saving data in .txt and use FileReader is convenient to get the data. What is the advantage of Using SQLite rather than File ?

How to delete tables and database using Sqiltehelper in android

I have created a class call DatabaseHandler extending SQLiteOpenHelper. I want to explicting deleted the database or table on the button click. What are the parameters I have to pass to the call method? Here is the code for reference: public class DatabaseHandler extends SQLiteOpenHelper { // All Static variables // Database Version public static […]

how to shrink sqlite database?

Once done storing all of my data into sqlite, it reach 14 MB already. That’s why I’m afraid that some people cannot download my application from connection slow area. Is there any way to shrink sqlite database?

How do I make a case insensitive query with ContentResolver in Android?

My goal is to get all rows from native db with a specific email address on Android Gingerbread and above. This query gets only the rows where the case also matches. Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, new String[] {Contacts._ID}, ContactsContract.CommonDataKinds.Email.ADDRESS + “=?”, new String[] {email}, null); I’ve read about WHERE clauses to sql where one use […]

Android SQLite select * from table where name like %key% using prepared statements

This question already has an answer here: cant use like clause in android app 6 answers

Version number for SQLite DB

I am working on sqlite in my android app. I am doing db.getVersion() to get current version of my database. it is showing 3 in logcat. even in constructor i set 4 as a version number. public Helper(Context context) { super(context, DATABASE_NAME, null,4); } i am giving 4 it should take 4 as version number. […]

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 ( […]

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