I have to admit here that I'm both new to Android and new to the DropBox API (but not new to development) so maybe I'm doing something wrong but I cannot get listFolder to return any files no matter what I try.
My code is below and the loop that gets the files is taken from the example API code. There is no issue conencting with the API but no matter what path I put in I either get nothing (if I use "") or an exception if use any other path.
One other thing I'm also confused about - once I've set up an app in the DropBox dashboard (say it's called MyTestApp) do I then need to create a folder of the same name in the root of my DropBox folder? If not, where is the folder for the app to be found? I am assuming using "" as the path is the same as saying DropBox/MyTestApp. I have 5 files of mixed type in this folder but the code never returns anything.... can anyone help me out to get this working?
public class MainActivity extends AppCompatActivity {
private List<TestClass> filesList;
final static private String APP_KEY = "yyyyyyyyyyyy";
final static private String ACCESS_TOKEN = "xxxxxxxxxxx";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//I KNOW THIS IS NOT GOOD CODE BUT I JUST WANT TO GET THE listFolder WORKING
//BEFORE MAKING A SEPERATE FUNCTION FOR THIS.
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
DropboxClientFactory dbFactory = new DropboxClientFactory(ACCESS_TOKEN);
DbxClientV2 client = dbFactory.getClient();
//TestClass is just a simlpe class with an integer and a string
filesList = new ArrayList<TestClass>();
try {
ListFolderResult result = client.files().listFolder("");
while (true) {
for (Metadata metadata : result.getEntries()) {
System.out.println(metadata.getPathLower()); //Never prints anything
filesList.add(new TestClass(metadata.getPathLower()));
}
if (!result.getHasMore()) {
break;
}
result = client.files().listFolderContinue(result.getCursor());
}
}
catch (DbxException ex)
{
System.out.println("EXCEPTION getting DropBox Files list: " + ex.getMessage());
}
}
}