Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /** Name of the table */
    private static final String TABLE_NAME = "s";

    /**
     * Read data of day "dayNumber" and returns the data as a cursor
     *
     * @param db
     *            pointer to database
     * @param dayNumber
     *            the day we want to read (1-31)
     * @param monthSelected
     *            the month we want to read from
     * @param yearSelected
     *            the year we want to read from
     * @return <code>Cursor</code> dayStamp
     *            Cursor with all database entries matching with dayNumber
     *            Entry per minute is
     *            cursor[0] = year stamp
     *            cursor[1] = month stamp
     *            cursor[2] = day stamp
     *            cursor[3] = hour stamp
     *            cursor[4] = minute stamp
     *            cursor[5] = sensor power
     *            cursor[6] = consumed power
     *            cursor[7] = light value
     */
    public static Cursor getDay(SQLiteDatabase db, int dayNumber, int monthSelected, int yearSelected) {
        return db
                .rawQuery(
                        "select * from " + TABLE_NAME + " where day= " + String.valueOf(dayNumber) + " and month= "
                                + String.valueOf(monthSelected) + " and year= " + String.valueOf(yearSelected),
                        null);
    }
}