0

I am having some trouble storing audio in the database in android using SQLite. I know people will say don't store in database performance, large files, once you reach the limit. I have a reason for storing in the database.

My intended goal is to record audio from the device and then store it as a blob to place it in the database. My next intention is to retrieve it as a blob and convert it back to the recorded audio file format. I am interested in using just about any format. maybe 3gp for the recording or mp3 i'm not really sure how the recording works because i am working on the database class for storing.

below is an example of something i am trying to do. The image file i have can easily be changed back using the BitmapFactory.decodeByteArray() but i have no idea what to use for audio files. keep in mind it's up for a change i can use any audio format recommended.

the main goal is to go from audio to blob and back

for (int i = 0; i < rows; i++) {
    Note note = new Note(cursor.getInt(_id),cursor.getString(_book), 
        cursor.getString(_chapter),cursor.getInt(_page), 
        BitmapFactory.decodeByteArray(cursor.getBlob(_image),
        0,
        cursor.getBlob(_image).length),
        cursor.getBlob(_audio));
    cursor.moveToNext();
}
sabadow
  • 5,095
  • 3
  • 34
  • 51
Lpc_dark
  • 2,834
  • 7
  • 32
  • 49
  • Both the `RECORD_SOUND_ACTION` intent and the `MediaRecorder` class give you a file, so why don't you want to use that? – CL. Dec 18 '12 at 14:56
  • Truth is i'm probably not at your level and i'm not sure what it is that you are talking about. could you explain a little bit futher? plus i want to store in database. How can i go from audio to blob and back – Lpc_dark Dec 18 '12 at 15:01
  • Just read the file into a byte array. – CL. Dec 18 '12 at 22:06
  • 1
    I believe this is exact duplicate of http://stackoverflow.com/questions/6341977/convert-drawable-to-blob-datatype-sqlite – mvp Dec 20 '12 at 03:20
  • Thanks you this is both informative and constructive. Was looking for ages for this – Lpc_dark Dec 20 '12 at 06:31

0 Answers0