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 android.database.sqlite.SQLiteDatabase;

import android.provider.BaseColumns;

public class Main {
    public static void createTable(final SQLiteDatabase db, final String tableName,
            final String[] columnsDefinition) {
        String queryStr = "CREATE TABLE " + tableName + "(" + BaseColumns._ID + " INTEGER  PRIMARY KEY ,";
        // Add the columns now, Increase by 2
        for (int i = 0; i < (columnsDefinition.length - 1); i += 2) {
            if (i != 0) {
                queryStr += ",";
            }
            queryStr += columnsDefinition[i] + " " + columnsDefinition[i + 1];
        }

        queryStr += ");";

        db.execSQL(queryStr);
    }
}