How to solve the out of memory error in android
<p>I am posting video to facebook. But out of memory exception is occuring.
         Iam posting video with 64 mb size. 
         Iam using Samsung galaxy Tab with sdcard of 2gb size.
         Could anyone please help me?Sorry for my english.</p>

<pre><code>       The logcat is:




      11-05 08:47:13.218: E/AndroidRuntime(2985): FATAL EXCEPTION: main

      11-05 08:47:13.218: E/AndroidRuntime(2985): java.lang.OutOfMemoryError

      11-05 08:47:13.218: E/AndroidRuntime(2985): at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)

      11-05 08:47:13.218: E/AndroidRuntime(2985):   at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:201)
</code></pre>

<p>public int postToFacebook(String msg, String caption, String mediaType,
                String path) {</p>

<pre><code>FileInputStream fis;
            ByteArrayOutputStream baos;
            fb = getFb();

            AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(fb);

            if (mediaType.equals("video")) {
            String filename = "";

               if (!path.equals("")) {

            try {

                if(!crossShareFlg.equals("yes")){
                   filename = path.substring(path.lastIndexOf("/") + 1,                                     path.length());
               fis = new FileInputStream(path);

               baos = new ByteArrayOutputStream();
            byte[] b = new byte[1024];
            int bytesRead;

            while ((bytesRead = fis.read(b)) != -1) {
            if (bytesRead &gt; 0) {
            baos.write(b, 0, bytesRead);
            } else {
            break;
            }
            }
            data = baos.toByteArray();
            fis.close();
            baos.close();
            }else{
            filename = path.substring(path.lastIndexOf("/") + 1,path.length());
            }


            }
            return 1;
        }
</code></pre>
