Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7754173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:14:30+00:00 2026-06-01T12:14:30+00:00

I started developing an android app that have to interact with MMS attachements, in

  • 0

I started developing an android app that have to interact with MMS attachements, in particular, get attachements such as text, bitmaps, audio, video etc. and store them on the phone in a specific folder.

So i started reading some books and some post on the web but it isn’t a very common argument, and i didn’t find an official way to do what i want to do.

I found a fairly good article here on stack-overflow here: How to Read MMS Data in Android?… it works very well for me, but there are 2 problems:

  1. The article shows you how to get MMS data by querying over the “hidden” SMS-MMS content provider, and as far as i know, Google doesn’t guarantee that they’ll keep the current structure in every android’s future relase.
  2. The article only explains how to get Text data and Bitmap data from MMS…what about video/audio? I tried to get a video/audio stream from an InputStream such as the example did with Bitmaps, unfortunately with no luck…

I’m very disappointed about the absence of official tutorial or “How-To” over this argument because SMS and MMS management is a very common need in mobile developement.
I hope someone can help me….

Thanks in advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:14:31+00:00Added an answer on June 1, 2026 at 12:14 pm

    I found a fairly simple way to read Video/Audio data from MMS, so i decided to publish this part of my class that provides MMS attachements, for all users that need this.

    private static final int RAW_DATA_BLOCK_SIZE = 16384; //Set the block size used to write a ByteArrayOutputStream to byte[]
    public static final int ERROR_IO_EXCEPTION = 1;
    public static final int ERROR_FILE_NOT_FOUND = 2;
    
    
    
    public static byte[] LoadRaw(Context context, Uri uri, int Error){
        InputStream inputStream = null;
        byte[] ret = new byte[0];
    
        //Open inputStream from the specified URI
        try {
            inputStream = context.getContentResolver().openInputStream(uri);
    
            //Try read from the InputStream
            if(inputStream!=null)
                ret = InputStreamToByteArray(inputStream);
    
        } 
        catch (FileNotFoundException e1) {
            Error = ERROR_FILE_NOT_FOUND;
        } 
        catch (IOException e) {
            Error = ERROR_IO_EXCEPTION;
        }
        finally{
            if (inputStream != null) {
                try {
                    inputStream.close();
                } 
                catch (IOException e) {
                    //Problem on closing stream. 
                    //The return state does not change. 
                    Error = ERROR_IO_EXCEPTION;
                }
            }
        }
    
    
        //Return
        return ret;
    }
    
    
    //Create a byte array from an open inputStream. Read blocks of RAW_DATA_BLOCK_SIZE byte
    private static byte[] InputStreamToByteArray(InputStream inputStream) throws IOException{
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        int nRead;
        byte[] data = new byte[RAW_DATA_BLOCK_SIZE];
    
        while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
          buffer.write(data, 0, nRead);
        }
        buffer.flush();
        return buffer.toByteArray();
    }
    

    In this way you can extract “Raw” data such as Audio/Video/Images from MMS by passing:

    1. the context where you need to use this function
    2. the URI of the MMS part that contains data you want to extract (for ex. “content://mms/part/2”)
    3. the byref param that returns an eventual error code thrown by the procedure.

    Once you have your byte[], you can create an empty File and then use a FileOutputStream to write the byte[] into it. If the file path\extension is correct and if your app has all the right
    permissions, you’ll be able to store your data.

    PS. This procedure has been tested a few times and it worked, but i don’t exclude can be some unmanaged exception cases that may produce error states. IMHO it can be improoved too…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i started developing apps in Titanium,in that i have already set android sdk path
I am developing on Android 2.3.3 (Gingerbread) and I have this particular activity that
I would like to get started with developing NFC apps for android. I have
I am just getting started developing my first Android app, and one function that
Yesterday I have started developing my first Metro style App using JavaScript. I've used
I am developing an Android app that connects to the Facebook Open Graph via
I used to have some experience with developing for android but I started up
I'm trying to get into Android app developing. My first problem is actually getting
i'm currently developing an app for both Android and iOS, thing is... I started
I am a new game developer and have started developing game for android. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.