protected Collection<FileInfo> loadFileInfos(long fileId) {
   final ArrayList<FileInfo> infos = new ArrayList<FileInfo>();
   while (fileId != -1) {
     final Cursor cursor =
         myDatabase.rawQuery(
             "SELECT name,size,parent_id FROM Files WHERE file_id = " + fileId, null);
     if (cursor.moveToNext()) {
       FileInfo info = createFileInfo(fileId, cursor.getString(0), null);
       if (!cursor.isNull(1)) {
         info.FileSize = cursor.getLong(1);
       }
       infos.add(0, info);
       fileId = cursor.isNull(2) ? -1 : cursor.getLong(2);
     } else {
       fileId = -1;
     }
     cursor.close();
   }
   for (int i = 1; i < infos.size(); ++i) {
     final FileInfo oldInfo = infos.get(i);
     final FileInfo newInfo = createFileInfo(oldInfo.Id, oldInfo.Name, infos.get(i - 1));
     newInfo.FileSize = oldInfo.FileSize;
     infos.set(i, newInfo);
   }
   return infos;
 }
  protected Collection<FileInfo> loadFileInfos(ZLFile file) {
    final LinkedList<ZLFile> fileStack = new LinkedList<ZLFile>();
    for (; file != null; file = file.getParent()) {
      fileStack.addFirst(file);
    }

    final ArrayList<FileInfo> infos = new ArrayList<FileInfo>(fileStack.size());
    final String[] parameters = {null};
    FileInfo current = null;
    for (ZLFile f : fileStack) {
      parameters[0] = f.getLongName();
      final Cursor cursor =
          myDatabase.rawQuery(
              (current == null)
                  ? "SELECT file_id,size FROM Files WHERE name = ?"
                  : "SELECT file_id,size FROM Files WHERE parent_id = "
                      + current.Id
                      + " AND name = ?",
              parameters);
      if (cursor.moveToNext()) {
        current = createFileInfo(cursor.getLong(0), parameters[0], current);
        if (!cursor.isNull(1)) {
          current.FileSize = cursor.getLong(1);
        }
        infos.add(current);
        cursor.close();
      } else {
        cursor.close();
        break;
      }
    }

    return infos;
  }
 protected Collection<FileInfo> loadFileInfos() {
   Cursor cursor = myDatabase.rawQuery("SELECT file_id,name,parent_id,size FROM Files", null);
   HashMap<Long, FileInfo> infosById = new HashMap<Long, FileInfo>();
   while (cursor.moveToNext()) {
     final long id = cursor.getLong(0);
     final FileInfo info =
         createFileInfo(
             id, cursor.getString(1), cursor.isNull(2) ? null : infosById.get(cursor.getLong(2)));
     if (!cursor.isNull(3)) {
       info.FileSize = cursor.getLong(3);
     }
     infosById.put(id, info);
   }
   cursor.close();
   return infosById.values();
 }