+
+ SharedPreferences appPreferences = PreferenceManager
+ .getDefaultSharedPreferences(getApplicationContext());
+
+ mSaveUploadLocation = appPreferences.getBoolean("save_last_upload_location", false);
+
+ //If the users has enabled last upload path saving then populate mParents with the previous path
+ if(mSaveUploadLocation)
+ {
+ String last_path = appPreferences.getString("last_upload_path", "");
+ // "/" equals root-directory
+ if(last_path.equals("/")) {
+ mParents.add("");
+ }
+ else{
+ String[] dir_names = last_path.split("/");
+ for (String dir : dir_names)
+ mParents.add(dir);
+ }
+ //Make sure that path still exists, if it doesn't pop the stack and try the previous path
+ while(!mStorageManager.fileExists(generatePath(mParents))){
+ mParents.pop();
+ }
+ }
+ else {
+ mParents.add("");
+ }
+