Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;

import java.util.ArrayList;

import java.util.List;

import android.os.Environment;

import android.util.Log;

public class Main {
    private static final String TAG = "NdroidHelper";

    public static List grabFiles() {
        List<String> tFileList = new ArrayList<String>();
        String p = Environment.getExternalStorageDirectory().getAbsolutePath() + "/nexsight/";
        File f = new File(p);

        Log.d(TAG, "Read from " + p);
        File[] files = f.listFiles();
        files = flipArray(files);
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                tFileList.add(file.getPath());
            }
        } else {
            Log.w(TAG, "nothing found in " + p);
        }

        return tFileList;
    }

    public static File[] flipArray(File[] b) {
        for (int left = 0, right = b.length - 1; left < right; left++, right--) {
            // exchange the first and last
            File temp = b[left];
            b[left] = b[right];
            b[right] = temp;
        }
        return b;
    }
}