zoukankan
html css js c++ java
Android 查找SDCard 下面的文件 函数
/* * searchFile 查找文件并加入到ArrayList 当中去 * @String keyword 查找的关键词 * @File filepath 查找的目录 * */ private void searchFile(String keyword,File filepath) { //判断SD卡是否存在 if (Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { File[] files = filepath.listFiles(); if (files.length > 0) { for (File file : files) { if (file.isDirectory()) { //如果目录可读就执行(一定要加,不然会挂掉) if(file.canRead()){ searchFile(keyword,file); //如果是目录,递归查找 } } else { //判断是文件,则进行文件名判断 try { if (file.getName().indexOf(keyword) > -1||file.getName().indexOf(keyword.toUpperCase()) > -1) { rowItem = new HashMap<String, Object>(); rowItem.put("number", index); // 加入序列号 rowItem.put("bookName", file.getName());// 加入名称 rowItem.put("path", file.getPath()); // 加入路径 rowItem.put("size", file.length()); // 加入文件大小 bookList.add(rowItem); index++; } } catch(Exception e) { Toast.makeText(this,"查找发生错误", Toast.LENGTH_SHORT).show(); } } } } } }
查看全文
相关阅读:
Leetcode 290 Word Pattern
Leetcode 205 Isomorphic Strings
Leetcode 345 Reverse Vowels in a String
Leetcode 151 Reverse Words in a String
Leetcode 344 Reverse String
Leetcode 383 Ransom Note
leetcode 387 First Unique Character in a String
反码补码和位运算
SpringBoot进阶
布隆过滤器
原文地址:https://www.cnblogs.com/javawebsoa/p/2458414.html
最新文章
工作 一 发布订单的 消息验证( 也就是一个关于消息遍历隐藏内容)
网站开发的全过程
数组去重
JavaScript 公有 私有 静态属性和方法
JS 事件冒泡整理 浏览器的事件流
Less 教程
HTTP解析
_bzoj1051 [HAOI2006]受欢迎的牛【强联通】
_bzoj1015 [JSOI2008]星球大战starwar【并查集】
_bzoj1031 [JSOI2007]字符加密Cipher【后缀数组】
热门文章
_bzoj1003 [ZJOI2006]物流运输【预处理】
_bzoj1026 [SCOI2009]windy数【数位dp】
_bzoj1208 [HNOI2004]宠物收养所【Splay】
_bzoj2049 [Sdoi2008]Cave 洞穴勘测【LCT】
_bzoj2038 [2009国家集训队]小Z的袜子(hose)【莫队】
_bzoj1008 [HNOI2008]越狱【计数】
_bzoj1503 [NOI2004]郁闷的出纳员【Splay】
leetcode 87 Scramble String
leetcode 49 Group Anagram
leetcode242 Valid Anagram
Copyright © 2011-2022 走看看