Android Open Source - AndroidSqliteMultichoiceExample D B Contract






From Project

Back to project page AndroidSqliteMultichoiceExample.

License

The source code is released under:

Apache License

If you think the Android project AndroidSqliteMultichoiceExample listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Copyright 2014 Yehezkel (Zack) Yovel//w  w  w. j  a v  a2  s  .  c om
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package zack.examples.questiondb.database;

public final class DBContract {

  /**
   * Contract for the 'questions' table
   */
  public static abstract class QuestionsTable {
    public static final String TABLE_NAME = "questions";
    public static final String COLUMN_ID = "id";
    public static final String COLUMN_QUESTION = "question";
    public static final String COLUMN_SUBJECT = "subject";
    public static final String COLUMN_CORRECT_ANSWER_ID = "correct_answer_id";
    public static final String SCHEMA = "CREATE TABLE " + TABLE_NAME + "("
        + COLUMN_ID + " INTEGER PRIMARY KEY, " + COLUMN_QUESTION
        + " TEXT, " + COLUMN_SUBJECT + " TEXT, "
        + COLUMN_CORRECT_ANSWER_ID + " INTEGER, " + "FOREIGN KEY("
        + COLUMN_CORRECT_ANSWER_ID + ") " + "REFERENCES "
        + AnswersTable.TABLE_NAME + "(" + AnswersTable.COLUMN_ID + "));";
    public static final String DELETE_SCHEMA = "DROP TABLE IF EXISTS "
        + TABLE_NAME;
  }

  /**
   * Contract for the 'answers' table
   */
  public static abstract class AnswersTable {
    public static final String TABLE_NAME = "answers";
    public static final String COLUMN_ID = "id";
    public static final String COLUMN_ANSWER = "answer";
    public static final String COLUMN_QUESTION_ID = "question_id";
    public static final String SCHEMA = "CREATE TABLE " + TABLE_NAME + "("
        + COLUMN_ID + " INTEGER PRIMARY KEY, " + COLUMN_ANSWER
        + " TEXT, " + COLUMN_QUESTION_ID + " INTEGER, " + "FOREIGN KEY("
        + COLUMN_QUESTION_ID + ") REFERENCES "
        + QuestionsTable.TABLE_NAME + "(" + QuestionsTable.COLUMN_ID
        + "));";
    public static final String DELETE_SCHEMA = "DROP TABLE IF EXISTS "
        + TABLE_NAME;
  }

}




Java Source Code List

zack.examples.questiondb.MainActivity.java
zack.examples.questiondb.QuestionsActivity.java
zack.examples.questiondb.database.DBContract.java
zack.examples.questiondb.database.DataAccessObject.java
zack.examples.questiondb.database.QuestionsOpenHelper.java
zack.examples.qustiondb.entities.Question.java