为什么DocumentFile.getName需要比较长的时间?
Why does DocumentFile.getName take a relatively long time?
我看过。就我而言,它相当快,但对检索到的 DocumentFile 实例的操作需要很长时间。
DocumentFile[] aFiles = dfDir.listFiles(); //Takes 100 ms with a list of 250 files
//The following takes 5,000ms
for (DocumentFile df : aFiles) {
boolean bFoo = df.isDirectory(); //takes about 10ms
String sName = df.getName(); //takes about 10ms
}
有人能解释一下吗?
getName()
invokes ContentResolver#query()
under the hood ... [this] performs hundreds of queries, which is very inefficient."
来自对 的回答。
我看过
DocumentFile[] aFiles = dfDir.listFiles(); //Takes 100 ms with a list of 250 files
//The following takes 5,000ms
for (DocumentFile df : aFiles) {
boolean bFoo = df.isDirectory(); //takes about 10ms
String sName = df.getName(); //takes about 10ms
}
有人能解释一下吗?
getName()
invokesContentResolver#query()
under the hood ... [this] performs hundreds of queries, which is very inefficient."
来自对