Here you can find the source of getColumns(SQLiteDatabase db, String tableName)
Parameter | Description |
---|---|
db | Database that contains the table |
tableName | Table name to be used |
public static List<String> getColumns(SQLiteDatabase db, String tableName)
//package com.java2s; //License from project: Open Source License import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.util.Log; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { /**//from w ww .j a v a 2s. com * Get a list of column base_dictionary for the selected table * * @param db * Database that contains the table * @param tableName * Table name to be used * @return A List of column name */ public static List<String> getColumns(SQLiteDatabase db, String tableName) { List<String> ar = null; Cursor c = null; try { c = db.rawQuery("select * from " + tableName + " limit 1", null); if (c != null) { ar = new ArrayList<String>( Arrays.asList(c.getColumnNames())); } } catch (Exception e) { Log.v(tableName, e.getMessage(), e); e.printStackTrace(); } finally { if (c != null) c.close(); } return ar; } }