Question: I´m writing an application that relies on Ajax requests to retrieve data from a dataBase, the required info is delivered in a Json set of objects, this means that even for the empty fields of the dataBase a pair of propriety/value is generated:

```
[{"field1":"value1","field2":"value2","field3":""},{"field1":"","field2":"","field3":""}]

```

How can I Select only not empty fields from the dataBase via SQL avoiding generating and sending unnecessary data?

Answer: 
I advice using [`commons.io`](https://commons.apache.org/proper/commons-io/) library which handles symbolic links and extension resolution as well.

Task to scan for files with extensions:

```
import android.os.AsyncTask;
import android.os.Environment;
import android.util.Log;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class ScanTask extends AsyncTask<String,Void,ScanTask.Result> {

    @Override
    protected Result doInBackground(String... extensions) {

        if(extensions == null){
            extensions = new String[0];
        }

        List<File> files = new ArrayList<File>();
        boolean success = false;
        String status = "";

        if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
            try {
                files.addAll(FileUtils.listFiles(Environment.getExternalStorageDirectory(), extensions, true));
                success = true;
                status = "ok";
            } catch (Exception e) {
                Log.e("MyApp","File error:",e);
                success = false;
                status = "Scan error";
            }
        }else {
            success = false;
            status = "External storage not available";
        }

        return new Result(success,status,files);
    }

    public static class Result{
        public final boolean success;
        public final String message;
        public final List<File> files;

        public Result(boolean success, String message,List<File> files) {
            this.success = success;
            this.message = message;
            this.files = files;
        }
    }
}

```

Usage:

```
   ScanTask task = new ScanTask(){
        @Override
        protected void onPostExecute(Result result) {
            super.onPostExecute(result);

            if(result.success){
                List<File> files = result.files;
                //--do something with files--
            }else {
                String error = result.message;
                //--do something with error message--
            }
        }
    };

    task.execute("mp3","jpeg");

```
You can use this code:  

here is the [link](http://programondaspot.blogspot.com/2015/07/display-more-than-one-extension-files.html).

```
/**
  * Class to filter files which are having .mp3 extension
  * */
//you can choose the filter for me i put .mp3
class FileExtensionFilter implements FilenameFilter {
    public boolean accept(File dir, String name) {
        return (name.endsWith(".pdf" ) || name.endsWith(".docs" )) || name.endsWith(".3gp" ) ;
    }
}

```