Tag: sqlite

Insert or update in SQlite and Android using the database.query();

is there a way to change my function: public categorie createCategoria(String categoria) { ContentValues values = new ContentValues(); values.put(MySQLiteHelper.COLUMN_NOME, categoria); values.put(MySQLiteHelper.COLUMN_PREF, 0); long insertId = database.insert(MySQLiteHelper.TABLE_CATEGORIE, null, values); Cursor cursor = database.query(MySQLiteHelper.TABLE_CATEGORIE, allCategorieColumns, MySQLiteHelper.COLUMN_ID + ” = ” + insertId, null, null, null, null); cursor.moveToFirst(); categorie newCategoria = cursorToCategorie(cursor); cursor.close(); return newCategoria; } this is […]

Retrieving data from database to listview failed

My program contains an Activity class and a database class. The code I used to save the database values to ListView has some problems. The following is an inner class in the Activity: class getclicker extends ListActivity implements Button.OnClickListener { public void onClick(View v) { String datevalue = date.getText().toString(); String Userselectvalue = userSelection.getText().toString(); cursor1 = […]

Most efficient way to store arbitrary sort order?

I am currently working on an Android app where users can order their list via drag and drop in any order they want. Therefore, I must store the sort order in a variable in a column. I was thinking of giving each row a number like 100000, 200000, 300000, etc and if a user moves […]

How to synchronize SQLite and MySQL databases using push notifications?

I have an SQLite database on Android and a MySQL database on a server. I want to synchronize these databases when a user edits data on their phone or edits data on a website. I know how to update the MySQL database on the server when a user makes changes on their phone but I […]

SQLite database, multithreading, Locks and account sync on android

I’m trying to get a pattern that doesn’t fail for a multithreaded access to my sqlite database. Also, what is driving me nuts is that I can’t reproduce the issue. I have an app which uses a DB, but also Android Accounts and Android sync to sync my app’s data. My guess is that when […]

Android cursorwindow memory error in a specific fragment

I have an android app that uses a service to collect sensor data every 5ms and inserts it into a sqlite table. In a typical session there will be about 40mins of recordings. All of that code seems to be working fine. I have a strange problem where if the user navigates to a particular […]

Android SQLite – New table VS. new DB

I have a pretty complext DB on my app. When the time came to add more functionality, I started wondering whether I should implement it by adding more tables to the existing database, or open an entirely new database for the added functionality and add the tables there. Are there any ground rules regarding when […]

Maintaining a ListView where each List item has a one to many relationship

The way my app is set up is that I have a ListView, maintained by a CursorLoader, of posts made by the users. Each post has user comments that are associated with it. Each listitem has a custom textview at the bottom where the comments can be scrolled through(with a right or left swipe). Within […]

How to get contacts in order of their upcoming birthdays?

I have code to read contact details and to read birthdays. But how do I get a list of contacts in order of their upcoming birthday? For a single contact identified by id, I get details and birthday like this: Cursor c = null; try { Uri uri = ContentUris.withAppendedId( ContactsContract.Contacts.CONTENT_URI, id); c = ctx.getContentResolver().query(uri, […]

SQLite usage from activity and service

I have created a databaseprovider class which uses single instance of db object. Object is created in main activity and closed onDestroy method. This seems ok (but get some errors such as: db already closed or db is not open on some users devices that I cannot simulate). I want to add a service to […]

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