简体   繁体   English

幕后发生了什么?

[英]What is happening behind the scenes?

I came across the following code and I need some clarification about this code. 我遇到了以下代码,需要对此代码进行一些说明。

http://www.vogella.com/articles/AndroidSQLite/article.html#contentprovider_overview 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. 这仅是有效性检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM