Mega Code Archive
Create JSONObject
import java.io.File;
import org.json.JSONObject;
import org.json.JSONArray;
import android.os.Environment;
import android.util.Log;
class FileUtil {
public static JSONObject GetDirJSON(File dir)
{
JSONObject jsonObj=new JSONObject();
try
{
jsonObj.put("name", dir.getName());
jsonObj.put("directory", dir.isDirectory());
jsonObj.put("url", dir.getAbsolutePath());
if(dir.equals(Environment.getExternalStorageDirectory()))
{
jsonObj.put("root", true);
}
else
{
jsonObj.put("root", false);
jsonObj.put("parent", dir.getParent());
}
if(dir.isDirectory())
{
File[] subFs=dir.listFiles();
JSONArray array=new JSONArray();
for(int i=0;i