当前位置: 代码迷 >> Android >> How to get a tables columns arraylist on Android
  详细解决方案

How to get a tables columns arraylist on Android

热度:422   发布时间:2016-05-01 19:01:09.0
How to get a tables columns arraylist on Android?
Cursor ti = db.rawQuery("PRAGMA table_info(mytable)", null);    if ( ti.moveToFirst() ) {        do {            System.out.println("col: " + ti.getString(1));        } while (ti.moveToNext());    }
?

?

try {        Cursor c = db.query(tableName, null, null, null, null, null, null);        if (c != null) {            int num = c.getColumnCount();            for (int i = 0; i < num; ++i) {                String colname = c.getColumnName(i);            }        }    } catch (Exception e) {        Log.v(tableName, e.getMessage(), e);        e.printStackTrace();    }
?
  相关解决方案