Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.LinkedHashMap;
import java.util.Map;

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

public class Main {

    public static Map<String, Integer> getCity(SQLiteDatabase db, String tableName, int dqx_dqxx01,
            boolean municipalities) {
        Map<String, Integer> cityMap = new LinkedHashMap<String, Integer>();
        Cursor cursor = db.query(tableName, new String[] { "DQXX02", "DQXX01" }, "DQX_DQXX01=?",
                new String[] { "" + dqx_dqxx01 }, null, null, "DQXX01 ASC");
        if (cursor != null) {
            if (municipalities) {
                cursor.moveToNext();
            }
            while (cursor.moveToNext()) {
                cityMap.put(cursor.getString(0), cursor.getInt(1));
            }
        }
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
        return cityMap;
    }
}