1. It’s simple. Call the file selector in the system to help you find the file you need and return the path to you. The code is small and easy. It’s as simple as this:
2. Implement your own file manager and filter the file types you need by scanning the files on the system memory. It is a bit more complicated. It involves ContentResolver,Uri,Cursor,MediaStore,MimeType,Intent and other major knowledge points. It is definitely complicated and troublesome. Don't be afraid of trouble when you make something good, just go and eat it.
The first way lets you know what it is, and the second way lets you know why.
Write the word "wang" correctly, not "forget".
The second method is to give you these references and follow them to implement it yourself. That’s almost it.
First of all, let me solve your doubts about how to obtain all local video paths. When the Android system stores video, audio, pictures and other resources, it will automatically store its related information in the database. The information includes name, size, storage path, etc. If we play a certain video file, get its storage path from the database, and then get the video itself through the path. Then you need to do the following things: 1. Understand the name and fields of the database that stores Android video information 2. Understand the method of obtaining Android to obtain data in the database. Android has been packaged Look at the code for scanning all Video information. I searched casually, so I'm not sure it's correct. I'll explain it to you.
private void scanVideoUri(){
//通过ContentResolver从数据库获取信息,Curse是获取的结果
Cursor cursor = mContext.getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
null, null, null, null);
int totalCount =cursor.getCount();//计算所有结果的条数
cursor.moveToFirst();//此句一定要有
//遍历所有的Video信息
for( int i = 0;i < totalCount;i++){
String data = cursor.getString(cursor.getColumnIndex(MediaStore.MediaColumns.DATA));
String data1 = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA));
String title = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.TITLE));
String type = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.MIME_TYPE));
int id = cursor.getInt(cursor.getColumnIndex(MediaStore.Video.Media._ID));
Log.e(TAG, data+title+type);
cursor.moveToNext();//访问下一个
}
}
It’s normal if you don’t understand the code. Break the target down and then splice it together to get the final result.
Read the system database, and all the videos that can be seen in your mobile phone video list can be directly searched. For specific implementation, you can ask Du Niang~
Two ways
1. It’s simple. Call the file selector in the system to help you find the file you need and return the path to you. The code is small and easy. It’s as simple as this:
2. Implement your own file manager and filter the file types you need by scanning the files on the system memory. It is a bit more complicated. It involves
ContentResolver,Uri,Cursor,MediaStore,MimeType,Intent
and other major knowledge points. It is definitely complicated and troublesome. Don't be afraid of trouble when you make something good, just go and eat it.The first way lets you know what it is, and the second way lets you know why.
Write the word "wang" correctly, not "forget".
The second method is to give you these references and follow them to implement it yourself. That’s almost it.
First of all, let me solve your doubts about how to obtain all local video paths. When the Android system stores video, audio, pictures and other resources, it will automatically store its related information in the database. The information includes name, size, storage path, etc. If we play a certain video file, get its storage path from the database, and then get the video itself through the path. Then you need to do the following things:
1. Understand the name and fields of the database that stores Android video information
2. Understand the method of obtaining Android to obtain data in the database. Android has been packaged
Look at the code for scanning all Video information. I searched casually, so I'm not sure it's correct. I'll explain it to you.
It’s normal if you don’t understand the code. Break the target down and then splice it together to get the final result.
Read the system database, and all the videos that can be seen in your mobile phone video list can be directly searched. For specific implementation, you can ask Du Niang~
http://blog.csdn.net/github_3... This tutorial is good