Execute SQL Statement using SQLiteDatabase - Android Database

Android examples for Database:SQL Query

Description

Execute SQL Statement using SQLiteDatabase

Demo Code


//package com.java2s;

import android.database.sqlite.SQLiteDatabase;

import android.util.Log;

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

    /**/* w w  w  .  j a v a2 s.  c om*/
     * Creates the game engine table. This table used to store the types of game engines
     * @param db
     */
    private static void createGameEngineTable(SQLiteDatabase db) {
        Log.d(LOG_TAG, "Creating game engine table");

        StringBuilder sql = new StringBuilder();
        sql.append("CREATE TABLE GameEngine(");
        sql.append("Id smallint PRIMARY KEY,");
        sql.append("Name nvarchar(30)");
        sql.append(");");

        db.execSQL(sql.toString());
    }
}

Related Tutorials