I came across the following code and I need some clarification about this code.
http://www.vogella.com/articles/AndroidSQLite/article.html#contentprovider_overview
private void checkColumns(String[] projection) {
String[] available = { TodoTable.COLUMN_CATEGORY,
TodoTable.COLUMN_SUMMARY, TodoTable.COLUMN_DESCRIPTION,
TodoTable.COLUMN_ID };
if (projection != null) {
HashSet<String> requestedColumns = new HashSet<String>(
Arrays.asList(projection));
HashSet<String> availableColumns = new HashSet<String>(
Arrays.asList(available));
// Check if all columns which are requested are available
if (!availableColumns.containsAll(requestedColumns)) {
throw new IllegalArgumentException(
"Unknown columns in projection");
}
}
}
My question is: As hashset is used to compare the values what is going on behind the scenes? Is hashset storing the data of tables in it ? If yes then may I use this value in another program and also print out in consoles ?
I am not sure what is happening , please explain it.
thanks.
The purpose of the code you pasted in is only to check that the user did not give columns in the projection that don’t exist in a table. There’s no query made against the specified table, no data extracted. This is only a validity check.