返回在Android的一个SQLite表中的所有列 [英] Return all columns of a SQLite table in Android
本文介绍了返回在Android的一个SQLite表中的所有列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的SQLite数据库表进行添加列,每当我需要。我不想硬$ C C柱$在更新数据库,并忘记更新硬codeD值的风险。我怎么能返回列的所有名称在一个表? (preferably在的String []
)
The SQLite database table I'm using is subjected to adding columns whenever I need to. I don't want to hard-code the columns at the risk of updating the database and forgetting to update the hard-coded values. How could I return all the names of the columns in a table? (Preferably in a String[]
)
推荐答案
最好的,如果你使用 SQLiteDatabase
实例,并使用查询方法
Best if you use a SQLiteDatabase
instance and use query method
SQLiteDatabase mDataBase;
(some code here...)
mDataBase = getReadableDatabase();
Cursor dbCursor = mDataBase.query(TABLE_NAME, null, null, null, null, null, null);
String[] columnNames = dbCursor.getColumnNames();
columnNames
应具备的列名
这篇关于返回在Android的一个SQLite表中的所有列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文