Creates the SQL used by the database to create an index in a table. - Android Database

Android examples for Database:Table Index

Description

Creates the SQL used by the database to create an index in a table.

Demo Code


//package com.book2s;

public class Main {
    /**// ww  w .j  a  va 2s  .com
     * Creates the string used by the database to create an index in a table.
     * This string can be used in the function
     * {@link SQLiteDatabase#execSQL(String)}
     * 
     * @param tableName The name of the table
     * @param columnName The name of the column to index
     * @return The index string
     */
    public static String getCreateIndexString(final String tableName,
            final String columnName) {
        return "create index " + tableName.toLowerCase() + '_' + columnName
                + " on " + tableName + " (" + columnName + ");";
    }
}

Related Tutorials