Android Sqlite database schema
android, sqlite
Solution
You can do it with code. Sqlite has a table called "sqlite_master " which holds the schema information.
/**
* Get all table Details from the sqlite_master table in Db.
*
* @return An ArrayList of table details.
*/
public ArrayList<String[]> getDbTableDetails() {
Cursor c = db.rawQuery(
"SELECT name FROM sqlite_master WHERE type='table'", null);
ArrayList<String[]> result = new ArrayList<String[]>();
int i = 0;
result.add(c.getColumnNames());
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
String[] temp = new String[c.getColumnCount()];
for (i = 0; i < temp.length; i++) {
temp[i] = c.getString(i);
}
result.add(temp);
}
return result;
}
A more simple way is to run it on the emulator .
- open ddms perspective
- Find data/data/PACKAGENAME/database/YOURFILE
- Click the pull from db button on top right shown in picture.
Open
Problem
I think I have created an sqllite database with android but every time I go to do an insert it claims a column does not exist. How can I view the schema and is the onCreate method called on object creation?