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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:38:50+00:00 2026-06-11T23:38:50+00:00

I am getting a video URL from server with the help of JSON .

  • 0

I am getting a video URL from server with the help of JSON.

How can I save it in my android project? (I want to send this Video through Email also.)

  • 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-06-11T23:38:51+00:00Added an answer on June 11, 2026 at 11:38 pm

    Try this,

    public String downloadImages(String serverUrl,String directory)
        {
    
            if (serverUrl == null)
                return null;
    
            String LocalFilePath=serverUrl.substring(serverUrl.lastIndexOf("/")+1, serverUrl.length());
            File file =  new File(directory, LocalFilePath);
             if (!file.exists())
             {
                    int bytesread = 0;
                    byte[] bytes = new byte[1024];  
                    InputStream strm = null;
                    HttpResponse response = null;
                    HttpEntity entity = null;
                    String LocalFile = null;
                    FileOutputStream foStream;
                    BufferedOutputStream writer = null;
                    try {
                        DefaultHttpClient httpclient = new DefaultHttpClient();
                        serverUrl = serverUrl.replace(" ", "%20");
                        HttpGet httpget = new HttpGet(serverUrl);   
    
                        response = httpclient.execute(httpget);
    
                        if (response == null) 
                        {
                            return null;
                        }
                        entity = response.getEntity();
                        strm = entity.getContent();         
                        File dire = new File(directory);
                        if (!dire.isDirectory()) 
                        {
                            dire.mkdirs();
                        }
                        LocalFile = directory+LocalFilePath;
                        directory = null;
                        foStream = new FileOutputStream(LocalFile);
                        writer = new BufferedOutputStream(foStream);            
    
                        do 
                        {
                            bytesread = strm.read(bytes, 0, bytes.length);
                            if(bytesread > 0)
                            {   
                                writer.write(bytes, 0, bytesread);
                                writer.flush();
                            }
                        } while (bytesread > 0);                    
    
                        writer.close();
                        foStream.close();
    
                        strm.close();               
                        return LocalFile;
                    }
                    catch(Exception e)  
                    {   
                        file.delete();
                        e.printStackTrace();
                        return null;
                    }   
             }
             else
             {
                 return "file exist";
             }
        }
    

    This will download file from server and save at your given filepath

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

Sidebar

Related Questions

I am getting a url from server & i want to save video in
I need to share one video url getting from my server in twitter. And
I want to play video of mp4 format and size 4-5Mb from server in
Im getting this error: Unsafe JavaScript attempt to access frame with URL URL1 from
I want to download say 10 different video from a url at different path,lets
In my project, I used MPMoviePlayerController to stream video from an http url. It
I'm stuck with this code, I'm getting this json formated data from the Youtube
I am new in Android, i want to fetch the video file from web
How to prevent Javascript Menu from getting hidden under Flash Video (SWFObject ). I
I'm having great difficulty getting my Android application to play videos from the SD

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.