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 6135005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:25:36+00:00 2026-05-23T17:25:36+00:00

In my android app I can record audio and save it on the phone/sdk.

  • 0

In my android app I can record audio and save it on the phone/sdk. I checked that it is audible and clear when i play it back on the phone. The size of the audio file it created is 5.9kb(.amr format).
Next i upload the file to the server, it stores the audio on sql db. The upload is successful. When the uploaded audio is played, it is all garbled…

In the database i store the audio in a column with datatype image and is of length 16.

My question is ..why is the noise garbled after upload. How do i verify that the audio is saved correctly without any noise added.

Code for file upload

InputStream = new DataInputStream(new FileInputStream( FileName));
            byte[] responseData = new byte[10000];   
            int length = 0;   
            StringBuffer rawResponse = new StringBuffer();   
            while (-1 != (length = InputStream.read(responseData)))
                rawResponse.append(new String(responseData, 0, length));   
            String finalstring = rawResponse.toString();
voicedataArray = finalstring.getBytes();
  • 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-05-23T17:25:37+00:00Added an answer on May 23, 2026 at 5:25 pm

    Your problem is very much likely due to the use of StringBuffer to buffer the response. A character in Java is a two-byte entity corresponding to a Unicode character point. The documentation for String#getBytes() says:

    Returns a new byte array containing the characters of this string
    encoded using the system’s default charset.

    So there’s no guarantee that the bytes you are passing in, being converted to characters, then back to bytes is the same stream you passed in the first place.

    I think you would need to code your solution using a dynamically expanding byte buffer in place of the StringBuffer.

    Also, two notes about the usage of StringBuffer:

    1) All accesses to the StringBuffer are synchronized, so you’re paying a performance penalty. StringBuilder is a modern-day replacement that doesn’t do synchronization under the hood.

    2) Each time you append to the StringBuffer:

    rawResponse.append(new String(responseData, 0, length));
    

    you are allocating a new string and throwing it away. That’s really abusive to the garbage collector. StringBuffer actually has a form of append() that will directly take a char array, so there is no need to use an intermediate String. (But you probably don’t want to use a StringBuffer in the first place).

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

Sidebar

Related Questions

I have an Android app that allows the user to record data (such as
I'm working on an android app that can call upon HP ePrint app to
I have an android app that records audio and does other stuff, and I
I have an upload phone app that uploads either images or audio recordings. The
I am writing an Android app which can take pictures and save them on
Can anyone share app/ways to record current android screen device? i know this app:
I'm writing an Android app where users can upload video to Youtube. I'd like
I've just started debugging my first three line long android app and I can't
How can I build an android app which basically get the inputs from user
im wondering if we can develop our android app in any computer we use

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.