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: 
```
public void walkdir(File dir) {
    String pdfPattern = ".pdf";

    File[] listFile = dir.listFiles();

    if (listFile != null) {
        for (int i = 0; i < listFile.length; i++) {

            if (listFile[i].isDirectory()) {
                walkdir(listFile[i]);
            } else {
              if (listFile[i].getName().endsWith(pdfPattern)){
                              //Do what ever u want

              }
            }
        }
    }    }

```

To search on the whole sdcard call this function using`walkdir(Environment.getExternalStorageDirectory());`
Use [getExternalStorageDirectory ()](http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory%28%29) to get the SD card path. (Do not hardcode it)

Loop through each subfolder, and check files names with your desired extension. Use String [endswith()](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#endsWith%28java.lang.String%29) method to check if file name ends with the extension.

[Here's a sample code](http://www.mkyong.com/java/how-to-find-files-with-certain-extension-only/) that might help you.