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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:43:14+00:00 2026-05-23T03:43:14+00:00

I am creating an application in which i need to read sdcard images. I

  • 0

I am creating an application in which i need to read sdcard images. I want to put background image for the IMAGE folder, how to set that?
please reply if more info required

  • 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-05-23T03:43:14+00:00Added an answer on May 23, 2026 at 3:43 am
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FilenameFilter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.List;
    import java.util.Vector;
    import java.util.zip.GZIPInputStream;
    import java.util.zip.GZIPOutputStream;
    
    import com.androidpeople.tab.FindFilesByType.DownloadFileAsync;
    
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.ExpandableListActivity;
    import android.app.ProgressDialog;
    import android.content.Context;
    import android.content.res.Resources;
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.os.Environment;
    import android.util.Log;
    import android.view.KeyEvent;
    import android.widget.ArrayAdapter;
    import android.widget.ExpandableListView;
    import android.widget.ProgressBar;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.widget.ExpandableListView.OnGroupExpandListener;
    
    public class SongList extends ExpandableListActivity {
        private RingtoneAdapter expListAdapter;
        public static SongList self;
    
        int myProgress = 0;
        public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
        ProgressBar myProgressBar;
        ProgressDialog mProgressDialog;
        List<String> items = new ArrayList<String>();
        final Context myApp = this;
        // private static final String DIRECTORY = "/system/media/audio/ringtones/";
        private static final String DIRECTORY = "/sdcard/download/";
    
    //  private MediaPlayer mp = new MediaPlayer();
        List<String> Ringtones = new ArrayList<String>();
        ArrayAdapter<String> adapter;
        TextView tv, empty;
        ExpandableListView exlv1;
        // ListView lv1;
        Boolean hasErrors = false;
        int currentPosition = 0;
        private static final String LOG_TAG = "TEST";
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            self=this;
            setContentView(R.layout.main);
            refreshList();
    
        }   
        }   
        public void refreshList() {
    
            File ringtones_directory = new File(DIRECTORY);
            if (!ringtones_directory.exists()) {
                AlertDialog.Builder ad = new AlertDialog.Builder(SongList.this);
                ad.setTitle("Directory Not Found");
                ad.setMessage("Sorry! The ringtones directory doesn't exist.");
                ad.setPositiveButton("OK", null);
                ad.show();
                hasErrors = true;
            }
            if (!ringtones_directory.canRead()) {
                AlertDialog.Builder ad = new AlertDialog.Builder(SongList.this);
                ad.setTitle("Permissions");
                ad
                        .setMessage("Sorry! You don't have permission to list the files in that folder");
                ad.setPositiveButton("OK", null);
                ad.show();
                hasErrors = true;
            } else {
                Ringtones = FindFiles(false);
    
                if (Ringtones.size() < 1) {
                    AlertDialog.Builder ad = new AlertDialog.Builder(SongList.this);
                    ad.setTitle("Permissions");
                    ad.setMessage("Sorry! No ringtones exists in " + DIRECTORY
                            + ".");
                    ad.setPositiveButton("OK", null);
                    ad.show();
                    Log.e(LOG_TAG, "No ringtones were found.");
                    hasErrors = true;
                }
            }
            try {
                if (!hasErrors) {
                    ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                            SongList.this, android.R.layout.test_list_item,
                            Ringtones);
                    ArrayList<String> GrouppList = new ArrayList<String>();
                    GrouppList.addAll(Ringtones);
                    ArrayList<ArrayList<Rington>> colors = new ArrayList<ArrayList<Rington>>();
                    for (int i = 0; i <= Ringtones.size(); i++) {
                        ArrayList<Rington> color = new ArrayList<Rington>();
                        color = new ArrayList<Rington>();
                        color.add(new Rington("", "", true));
                        colors.add(color);
                    }
                    expListAdapter = new RingtoneAdapter(this, GrouppList, colors);
                            exlv1 = (ExpandableListView) findViewById(R.id.expandableListView1);
                                this.exlv1.setAdapter(this.expListAdapter);
    
                }               
    
            } catch (Exception e) {     
                Log.i(LOG_TAG, e.toString());
            }
        }
    
        private List<String> FindFiles(Boolean fullPath) {
            final List<String> tFileList = new ArrayList<String>();
            Resources resources = getResources();
            // array of valid audio file extensions
            String[] audioTypes = resources.getStringArray(R.array.audio);
            FilenameFilter[] filter = new FilenameFilter[audioTypes.length];
            int i = 0;
            for (final String type : audioTypes) {
                filter[i] = new FilenameFilter() {
                    public boolean accept(File dir, String name) {
                        return name.endsWith("." + type);
                    }
                };
                i++;
            }
            FileUtils fileUtils = new FileUtils();
            File[] allMatchingFiles = fileUtils.listFilesAsArray(
                    new File(DIRECTORY), filter, -1);
            for (File f : allMatchingFiles) {
                if (fullPath) {
                    tFileList.add(f.getAbsolutePath());
                } else {
                    tFileList.add(f.getName());
                }
            }
            return tFileList;
        }// find fil
    
        @SuppressWarnings("unchecked")
        public List<String> loadArray(String filename) {
            try {
                FileInputStream fis = new FileInputStream(filename);
                GZIPInputStream gzis = new GZIPInputStream(fis);
                ObjectInputStream in = new ObjectInputStream(gzis);
                List<String> read_field = (List<String>) in.readObject();
                in.close();
                return read_field;
            } catch (Exception e) {
                e.getStackTrace();
            }
            return null;
        }
    
        public Collection<File> listFiles(File directory, FilenameFilter[] filter,
                int recurse) {
    
            Vector<File> files = new Vector<File>();
    
            File[] entries = directory.listFiles();
    
            if (entries != null) {
                for (File entry : entries) {
                    for (FilenameFilter filefilter : filter) {
                        if (filter == null
                                || filefilter.accept(directory, entry.getName())) {
                            files.add(entry);
                            Log.v(LOG_TAG, "Added: " + entry.getName());
                        }
                    }
                    if ((recurse <= -1) || (recurse > 0 && entry.isDirectory())) {
                        recurse--;
                        files.addAll(listFiles(entry, filter, recurse));
                        recurse++;
                    }
                }
            }
            return files;
    
        }
    
        public class FileUtils {
    
            public void saveArray(String filename, List<String> output_field) {
                try {
                    FileOutputStream fos = new FileOutputStream(filename);
                    GZIPOutputStream gzos = new GZIPOutputStream(fos);
                    ObjectOutputStream out = new ObjectOutputStream(gzos);
                    out.writeObject(output_field);
                    out.flush();
                    out.close();
                } catch (IOException e) {
                    e.getStackTrace();
                }
            }
    
            public File[] listFilesAsArray(File directory, FilenameFilter[] filter,
                    int recurse) {
                Collection<File> files = listFiles(directory, filter, recurse);
    
                File[] arr = new File[files.size()];
                return files.toArray(arr);
            }
        }
    
    }
    

    The above code will list all the below contain extention files from sdcard you can change them according to your requirement Happy coding :Pragna

    this is mimetypes.xml inside the res folder

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <string-array name="audio">
    <item>aif</item>
    <item>aifc</item>
    <item>aiff</item>
    <item>au</item>
    <item>mid</item>
    <item>mp3</item>
    <item>ogg</item>
    <item>snd</item>
    <item>wav</item>
    </string-array>
    </resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a Java application in which I need to read the first
I am creating a moderating application in which i need to fetch all the
I am creating an application which produces some files/directories in my WebContent folder and
I am creating a C# application which will have to upload and read data
I'm creating an application in C# 3.5 that uses the AutoCAD API to read
I'm creating an application which communicates with the device via FT2232H USB/RS232 converter. For
I am creating an application which tracks the users location using GPS, stores the
I am creating an application which involves so many web-service calls. I am using
I am creating Facebook application which get insights for user's page for multiple metric.
I am creating a Silverlight application which will be heavily javascripted against. To enable

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.