logo
down
shadow

filter mp3 files from other media files using MediaStore & MediaMetadataRetriever?


filter mp3 files from other media files using MediaStore & MediaMetadataRetriever?

By : user2952672
Date : November 19 2020, 01:01 AM
I wish this help you You can do it by below code which use MediaStore.Please add the external storage permission. android:name="android.permission.WRITE_EXTERNAL_STORAGE"
The code is -
code :
public ArrayList<HashMap<String, String>> getSDCardAudioFiles() {
        // if you want  file path and additional details
        ArrayList<HashMap<String, String>> audioFilesDetailList = new ArrayList<HashMap<String, String>>();
        // if you want only file path
        ArrayList<String> audioFilePath =new ArrayList<String>();
        // if you want only file name
        ArrayList<String> audioFileName =new ArrayList<String>();
            Cursor mCursor = getContentResolver().query(
                    MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                    new String[] { MediaStore.Audio.Media.DISPLAY_NAME,
                            MediaStore.Audio.Media.DATA }, null, null, null);

            int count = mCursor.getCount();

            HashMap<String, String> audioFileMap;
            while (mCursor.moveToNext()) {
                audioFileMap = new HashMap<String, String>();
                audioFileMap.put("FileName",mCursor.getString(mCursor
                                .getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME)));
                audioFileMap.put("FilePath", mCursor.getString(mCursor
                        .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)));
                if(audioFileMap.get("FileName").endsWith(".mp3")){
                    audioFilesDetailList.add(audioFileMap);

                    // if you want only file path
                    audioFilePath.add(audioFileMap.get("FilePath"));
                     // if you want only file name 
                    audioFileName.add(audioFileMap.get("FileName"));
                }
            }
            mCursor.close();
            //return the arraylist whichever u needed
            return audioFilesDetailList;
        }


Share : facebook icon twitter icon
In Android, how do I query MediaStore only for files in a specific path? Or alternatively, only display files in a certa

In Android, how do I query MediaStore only for files in a specific path? Or alternatively, only display files in a certa


By : RakeshKumar
Date : March 29 2020, 07:55 AM
To fix this issue OK, after many iterations of trying, I finally have an example that works and I thought I'd share it. My example queries the images MediaStore, then obtains the thumbnail for each image to display in a view. A few tweaks should provide you with the code needed to query the audio MediaStore instead. I am loading my images into a Gallery object, but that is not a requirement for this code to work:
Make sure you have a Cursor and int for the column index defined at the class level so that the Gallery's ImageAdapter has access to them:
code :
private Cursor cursor;
private int columnIndex;
Gallery g = (Gallery) findViewById(R.id.gallery);
// request only the image ID to be returned
String[] projection = {MediaStore.Images.Media._ID};
// Create the cursor pointing to the SDCard
cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
        projection, 
        MediaStore.Images.Media.DATA + " like ? ",
        new String[] {"%myimagesfolder%"},  
        null);
// Get the column index of the image ID
columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);
g.setAdapter(new ImageAdapter(this));
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView i = new ImageView(context);
    // Move cursor to current position
    cursor.moveToPosition(position);
    // Get the current value for the requested column
    int imageID = cursor.getInt(columnIndex);
    // obtain the image URI
    Uri uri = Uri.withAppendedPath( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(imageID) );
    String url = uri.toString();
    // Set the content of the image based on the image URI
    int originalImageId = Integer.parseInt(url.substring(url.lastIndexOf("/") + 1, url.length()));
    Bitmap b = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(),
                    originalImageId, MediaStore.Images.Thumbnails.MINI_KIND, null);
    i.setImageBitmap(b);
    i.setLayoutParams(new Gallery.LayoutParams(150, 100));
    i.setScaleType(ImageView.ScaleType.FIT_XY);
    i.setBackgroundResource(mGalleryItemBackground);
    return i;
}
MediaStore - Uri to query all types of files (media and non-media)

MediaStore - Uri to query all types of files (media and non-media)


By : Cédric Cob
Date : March 29 2020, 07:55 AM
it should still fix some issue It is "external" or "internal" although internal (system files) is probably not useful here.
code :
ContentResolver cr = context.getContentResolver();
Uri uri = MediaStore.Files.getContentUri("external");

// every column, although that is huge waste, you probably need
// BaseColumns.DATA (the path) only.
String[] projection = null;

// exclude media files, they would be here also.
String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "="
        + MediaStore.Files.FileColumns.MEDIA_TYPE_NONE;
String[] selectionArgs = null; // there is no ? in selection so null here

String sortOrder = null; // unordered
Cursor allNonMediaFiles = cr.query(uri, projection, selection, selectionArgs, sortOrder);
// only pdf
String selectionMimeType = MediaStore.Files.FileColumns.MIME_TYPE + "=?";
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension("pdf");
String[] selectionArgsPdf = new String[]{ mimeType };
Cursor allPdfFiles = cr.query(uri, projection, selectionMimeType, selectionArgsPdf, sortOrder);
Is it possible to filter or remove results shown when using PICK_ACTION and MediaStore.Audio.Media.EXTERNAL_CONTENT_URI?

Is it possible to filter or remove results shown when using PICK_ACTION and MediaStore.Audio.Media.EXTERNAL_CONTENT_URI?


By : Meenakshi Ravikumar
Date : March 29 2020, 07:55 AM
hop of those help? No, it does not seem possible at this time. I ended up writing my own activity for selection and it queries the media store as appropriate.
The solution can be found here:
MediaMetadataRetriever returns null but fine with MediaStore

MediaMetadataRetriever returns null but fine with MediaStore


By : Hwang
Date : March 29 2020, 07:55 AM
seems to work fine Do you know this - http://developer.android.com/reference/android/media/MediaMetadataRetriever.html
code :
MediaMetadataRetriever metaRetriver;
metaRetriver = new MediaMetadataRetriever();
metaRetriver.setDataSource("/sdcard/audio.mp3");

try {
        byte [] art = metaRetriver.getEmbeddedPicture();
        Bitmap songImage = BitmapFactory
            .decodeByteArray(art, 0, art.length);
        metaRetriver.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM));
        String artist = metaRetriver
                .extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST));
        String genre = metaRetriver
                .extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE));
    } catch (Exception e) {
         // TO-DO Exception
    }
How can I get all .pdf files from Internal as well as External storage using MediaStore.Files in Android

How can I get all .pdf files from Internal as well as External storage using MediaStore.Files in Android


By : trml
Date : March 29 2020, 07:55 AM
Does that help May be it is late , but i finally get the solution for as you asked for multiple file extension like .doc, pdf , xls.
Related Posts Related Posts :
  • Stream corrupted exception - invalid code type AC [java]
  • Routing Sysout values to JTextArea
  • GWT RPC serialization for Dynamic Host Page
  • Best Approch of Returning Value from 'getter' Method
  • Understanding xml schemalocation
  • Checking if a PDF is PDF/A 1-a format or not using PDFBOX in java
  • Difference Between Variable and Identifier
  • How to compute two aggregate functions with Java streams?
  • Parse the value of the json to baseadapter in android?
  • JavaFX animation on raspberry pi
  • Solve "unchecked warning" in Java avoiding @suppressWarnings
  • How to specify a new name for a file while moving it to another directory in Java?
  • Popup window not showing up with spinner item selection?
  • how to iterate through json objects in java
  • Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor
  • Getting NoClassDefFoundError while running PMD task from Gradle
  • Matlab drag and drop file from windows explorer to figure (gui)
  • How does scala's actor model make use of C threads and native system threads?
  • Store java.util.Date as key in a Map based on reference equality instead of "value" equality
  • Error when logging into FTP from AsyncTask class using org.apache.commons.net.ftp.FTPClient
  • creating unique index in mongoDB
  • hibernate Query to find record based on substring
  • How many strings are in jvm string pool intern
  • Unable to initialize native-platform. on Jenkins
  • How to create a list of dummy files in Java?
  • Docker: Which approach is better? WAR embedded in image or base image + war?
  • java.lang.InternalError: CallerSensitive annotation expected at frame 1
  • How to write a method to read JSON files of different structures and return different POJO objects in Java?
  • Reference to Classes in Java
  • Unable to call function via companion object
  • REST: convert XML content passed with POST to a java object, attribute inside the element
  • Device not receive message from GCM
  • How to increase Openfire concurrent connection limit?
  • Android send custom parameter on AsyncTask
  • GWT - Get dom element's value from another page
  • How can i initialize an array in Java?
  • Is it possible to increase a java process's(when is running) size?
  • Getting Node Address instead of Value in Binary Search Tree
  • PdfByteContent not adding in iText pdf
  • Spring JpaRepository: delete() with subsequent save() in the same transaction
  • producer-consumer using arraydeque working only in breakpoint
  • Adding a JPanel to another JPanel
  • Comparison with operator ==, how does it work?
  • Error buildling with maven for openshift
  • What is the java equivilant to MySQL's smallint
  • proxy trouble on eclipse with https
  • Spring-Jdbc Template and Prepared statement
  • Mule - exception in Outbound endpoint Message payload is of type: byte[]
  • Modify package names for java classes generated from wsdl
  • How to download multiple images and have one progressBar using AsynTask (Android)
  • Implementing Service Provider, IdP and user in java with SAML (POC)
  • Why does my scanner repeat?
  • Can I forget ResultSetFuture in Cassandra java driver without facing memory leak?
  • XML to JAXB binding having nested elements?
  • Java: ToString() prints the same hashcode each time
  • Why am I getting a thread exception in my graphics program?
  • Can we read 4th byte from hexadecimal value?
  • How to create watermark in image just like Google maps watermarks
  • how come Thread class called inside another class?
  • AssertionError: Unexpected schema version 0: Unexpected schema version 0
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org