Android examples for Database:Table Index
create Index for database table
//package com.book2s; import android.database.sqlite.SQLiteDatabase; import android.text.TextUtils; public class Main { private static final String INDEX_SFX = "_idx"; public static void createIndex(final SQLiteDatabase db, final String table, final String name, final String[] onColumns) { final StringBuilder indexSql = new StringBuilder(); indexSql.append("CREATE INDEX IF NOT EXISTS ").append(name); indexSql.append(INDEX_SFX).append(" ON ").append(table); indexSql.append("(").append(TextUtils.join(", ", onColumns)); indexSql.append(");"); db.execSQL(indexSql.toString()); }/*w w w.j a v a2 s . com*/ }