1

Can any one say how can I convert mp3 file to byte array,byte array to string and vice versa in android application. The mp3 file which is stored in sqlite database or loading from media folder.

thanks in advance

4
  • 1
    Well, that's two transformations - have you made any progress on either of them? (Base64 is probably the best byte[] to String conversion to use here.) Commented Jun 6, 2014 at 7:19
  • 1
    possible duplicate of this question: stackoverflow.com/questions/4280535/… Commented Jun 6, 2014 at 7:21
  • @ JonSkeet I have done earlier byte[] to string and string to byte[] now i am trying to convert mp3 to byte[] can you help me in this Commented Jun 6, 2014 at 7:22
  • It makes no sense to save an MP3 as a String. Commented Jun 6, 2014 at 7:28

1 Answer 1

1

You should not store media data into the database. Use the filesystem and place the the filename with path into the database... maybe with some additional meta information like length of the music, bytesize etc.

This will have more benefit for different services. The first is, that mp3 is nice for streaming. If you use a string for storage, you had to read the hole thing into the memory rather than a part. Rethink your application if someone stores audiobooks with hundred megabytes into you app.

If you really need to this you should treat your mp3 as a binary file and convert it late to base64.

See (for example)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.