zoukankan      html  css  js  c++  java
  • android 查找某个特定文件后缀名

     private void queryFiles(){
            String[] projection = new String[] { MediaStore.Files.FileColumns._ID,
                MediaStore.Files.FileColumns.DATA,
                MediaStore.Files.FileColumns.SIZE
            };
            Cursor cursor = getContentResolver().query(
                Uri.parse("content://media/external/file"),
                projection,
                MediaStore.Files.FileColumns.DATA + " like ?",
                new String[]{"%.txt"},
                null);
    
            if (cursor != null) {
                if (cursor.moveToFirst()) {
    
                    int idindex = cursor
                        .getColumnIndex(MediaStore.Files.FileColumns._ID);
                    int dataindex = cursor
                        .getColumnIndex(MediaStore.Files.FileColumns.DATA);
                    int sizeindex = cursor
                        .getColumnIndex(MediaStore.Files.FileColumns.SIZE);
                    do {
                        String id = cursor.getString(idindex);
                        String path = cursor.getString(dataindex);
                        String size = cursor.getString(sizeindex);
                        docBean.setId(id);
                        docBean.setPath(path);
                        docBean.setSize(size);
                        int dot=path.lastIndexOf("/");
                        String name=path.substring(dot+1);
                        Log.e("test",name);
                    } while (cursor.moveToNext());
                }
            }
            cursor.close();
        }
  • 相关阅读:
    Sql的基础知识(一)
    Django--分页功能
    django--基础操作
    CSRF攻击与防御(转载)
    谈谈CSRF
    浅谈Dom遍历
    node50行代码实现壁纸爬取
    node解决request中文乱码问题
    数组去重方法(转载)
    淘宝dns解析错误导致首页打不开
  • 原文地址:https://www.cnblogs.com/yzjT-mac/p/5831207.html
Copyright © 2011-2022 走看看