I need to add a new functionality into my app. I must store a lot of JPG 
images from internet into the Phone.

If the phone haves sdcard, the JPG files must be stored on the sdcard. If 
not, they must be stored on the internalMemory, only if the phone haves 
space to do it.

Then, i should do these things:

1. Check if the Phone haves SDCARD. If haves, SDCARD dir is the destiny, if 
not, INTERNAL MEMORY is the destiny.
2. Check if the phone have space to store the photos.
3. If have space, store the photos into a dir called `/Magazine/`

I know how to get a JPG file from internet and how to transform it into 
BITMAP, but it is the only think i know, i dont know how to store it as JPG 
and i dont know the other things.

    public static Bitmap getRemoteBitmap(String url) {        
        Bitmap bm=null;
        HttpClient httpclient = new DefaultHttpClient(); 
        HttpResponse response; 
        try { 
             ((AbstractHttpClient) 
httpclient).getCredentialsProvider().setCredentials(
                    new org.apache.http.auth.AuthScope(null,-1), 
                    new 
org.apache.http.auth.UsernamePasswordCredentials(MagazineStatus._username, 
MagazineStatus._password)); 
     
            response = httpclient.execute(new HttpGet(url)); 
            StatusLine statusLine = response.getStatusLine(); 
            if(statusLine.getStatusCode() == HttpStatus.SC_OK) { 
                try {                     
                    HttpEntity entity = response.getEntity();
                    InputStream content = entity.getContent();
                    bm=BitmapFactory.decodeStream(content );
                }catch(Exception ex) {Log.e("DBF 
Error",ex.toString());}                 
            }else { 
                response.getEntity().getContent().close(); 
                throw new IOException(statusLine.getReasonPhrase()); 
            } 
        }catch(ClientProtocolException cpe) {Log.e("ClientProtocolException 
@ at FPT",cpe.toString());} catch(Exception ex) {Log.e("Exception at 
FETCHPROJECTASK",ex.toString());} 
        return bm;
    }

I'm searching in google how to do the things i need, but i can't find any 
clear information, i prefeer to ask you for the best way to do this, the 
optimal way.

THanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to