Creates table and use smallint as column type - Android Database

Android examples for Database:Table Create

Description

Creates table and use smallint as column type

Demo Code


//package com.java2s;

import android.database.sqlite.SQLiteDatabase;

import android.util.Log;

public class Main {
    private static final String LOG_TAG = "BoardDatabaseOpenHelper";

    private static void createSavedGameTable(SQLiteDatabase db) {
        Log.d(LOG_TAG, "Creating saved game table");

        StringBuilder sql = new StringBuilder();

        sql.append("CREATE TABLE SavedGame (");
        sql.append("Engine smallint,");
        sql.append("Player smallint,");
        sql.append("PRIMARY KEY (Engine, Player),");
        sql.append("FOREIGN KEY (Engine) REFERENCES GameEngine(Id)");
        sql.append(");");

        db.execSQL(sql.toString());/*w ww .  j av a2  s . c  om*/
    }
}

Related Tutorials