import java.io.File;\r
 import java.io.InputStreamReader;\r
 import java.lang.Thread.UncaughtExceptionHandler;\r
-import java.net.URLEncoder;\r
 import java.util.ArrayList;\r
 \r
 import android.accounts.Account;\r
                         AccountUtils.getCurrentOwnCloudAccount(this));\r
                 String remotepath = new String();\r
                 for (int j = mDirectories.getCount() - 2; j >= 0; --j) {\r
-                    remotepath += "/" + URLEncoder.encode(mDirectories.getItem(j));\r
+                    remotepath += "/" + mDirectories.getItem(j);\r
                 }\r
                 if (!remotepath.endsWith("/"))\r
                     remotepath += "/";\r
-                remotepath += URLEncoder.encode(new File(filepath).getName());\r
+                remotepath += new File(filepath).getName();\r
+                remotepath = Uri.encode(remotepath, "/");\r
     \r
                 i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);\r
                 i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);\r
 \r
     @Override\r
     protected void onRestoreInstanceState(Bundle savedInstanceState) {\r
-        Log.e("ASD", "restore");\r
         super.onRestoreInstanceState(savedInstanceState);\r
         mDirs = savedInstanceState.getStringArray(KEY_DIR_ARRAY);\r
         mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);\r
     \r
     @Override\r
     protected void onSaveInstanceState(Bundle outState) {\r
-        Log.e("ASD", "save " + (mCurrentDir != null ? mCurrentDir.getFileName() : "NULL"));\r
         super.onSaveInstanceState(outState);\r
         if(mDirectories != null && mDirectories.getCount() != 0){\r
             mDirs = new String[mDirectories.getCount()-1];\r
             \r
                 // Clear intent extra, so rotating the screen will not return us to this directory\r
                 getIntent().removeExtra(FileDetailFragment.EXTRA_FILE);\r
-            } else {\r
-                mCurrentDir = mStorageManager.getFileByPath("/");\r
             }\r
+            \r
+            if (mCurrentDir == null)\r
+                mCurrentDir = mStorageManager.getFileByPath("/");\r
                 \r
             // Drop-Down navigation and file list restore\r
             mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);\r
                             }\r
     \r
                             // Figure out the path where the dir needs to be created\r
-                            String path = FileDisplayActivity.this.mCurrentDir.getRemotePath();\r
+                            String path;\r
+                            if (mCurrentDir == null) {\r
+                                if (!mStorageManager.fileExists("/")) {\r
+                                    OCFile file = new OCFile("/");\r
+                                    mStorageManager.saveFile(file);\r
+                                    mCurrentDir = mStorageManager.getFileByPath("/");\r
+                                } else {\r
+                                    Log.wtf("FileDisplay", "OMG NO!");\r
+                                    return;\r
+                                }\r
+                            }\r
+                            path = FileDisplayActivity.this.mCurrentDir.getRemotePath();\r
                             \r
                             // Create directory\r
-                            path += directoryName + "/";\r
+                            path += Uri.encode(directoryName) + "/";\r
                             Thread thread = new Thread(new DirectoryCreator(path, a));\r
                             thread.start();\r
     \r