1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to share the sqlite audio file to whatsapp or gmail?

Discussion in 'Android Development' started by selva_0707, Dec 30, 2020.

  1. selva_0707

    selva_0707 Lurker
    Thread Starter

    Hi guys,

    I am trying to share the audio file which is recorded and stored inside the app, using the SQLITE in which the path is stored. I need that audio files to shared in whats app and also attached in gmail.

    So i try to copy the audio file from sqlite to internal dir. but the file is not copyed and also i did not get any errors. When it is copied , i can use that local path to share option. But i am not able to do that.

    My work is to share the audio file to whatsapp and gmail.
    This is audio recording app, so the audio is recorded and stored inside the app, using the sqlite DB.
    I need that audio to be shared.

    And i tried this code

    Code (Text):
    1.    private void copyInputStreamToFile(File in, File file ) {
    3.     Log.d("fnamews", " 1");
    5.     try {
    6.         Log.d("fnamews", "2 " );
    7.         InputStream inStream = new FileInputStream(in);
    8.         OutputStream out = new FileOutputStream(file);
    9.         byte[] buf = new byte[1024];
    10.         int len;
    11.         while((len=inStream.read(buf))>0){
    12.             Log.d("fnamews", "3 " );
    13.             out.write(buf,0,len);
    14.         }
    15.         out.close();
    16.         inStream.close();
    17.     } catch (Exception e) {
    18.         e.printStackTrace();
    19.     }
    20. }

    Can any one help me to Share the audio file to whatsapp and gmail optionn?

    1. Download the Forums for Android™ app!



Share This Page