Execute select statement via SQLiteDatabase and return a cursor - Android Database

Android examples for Database:SQL Query

Description

Execute select statement via SQLiteDatabase and return a cursor

Demo Code


//package com.java2s;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class Main {
    public static Cursor getContacts(SQLiteDatabase db) {
        // Select All Query
        String selectQuery = "SELECT _id, name, number FROM contacts ORDER BY name ASC";
        Cursor cursor = db.rawQuery(selectQuery, null);

        return cursor;
    }//from w  w w.ja v  a2s.co  m
}

Related Tutorials