Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import android.content.ContentValues;

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

public class Main {
    public static final String TABLE_NAME = "dqxx";

    public static ArrayList<ContentValues> getProvince(SQLiteDatabase db) {
        ArrayList<ContentValues> list = new ArrayList<ContentValues>();
        ContentValues values = null;
        Cursor cursor = db.query(TABLE_NAME, new String[] { "DQXX01", "DQXX02" }, "DQXX03=?", new String[] { "1" },
                null, null, "DQX_DQXX01 ASC");
        if (cursor != null) {
            while (cursor.moveToNext()) {
                values = new ContentValues();
                values.put("province_id", cursor.getInt(0));
                values.put("province", cursor.getString(1));
                list.add(values);
            }
        }
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
        return list;
    }
}