fetch All Countries' name from SQLiteDatabase by table name - Android Database

Android examples for Database:Table Row Query

Description

fetch All Countries' name from SQLiteDatabase by table name

Demo Code


//package com.java2s;

import android.database.Cursor;

import android.database.sqlite.SQLiteDatabase;

public class Main {
    private final static String TABLE_NAME = "all_areas";

    public static Cursor fetchAllCountries(SQLiteDatabase sqliteDatabase) {
        Cursor cursor = null;//w  ww .  jav  a2s .  c  o m
        if (sqliteDatabase != null) {
            cursor = sqliteDatabase.query(true, TABLE_NAME,
                    new String[] { "resort_country" }, null, null, null,
                    null, null, null);
            if (cursor != null) {
                cursor.moveToFirst();
            }
        }
        return cursor;
    }
}

Related Tutorials