       (.superOnBackPressed this)
       (.setCurrentTabByTag tab-host source-tab-tag))))
 
+(defn -onActivityResult
+  [^org.turtle.geometry.TurtleGraphics this
+   request-code
+   result-code
+   ^Intent data]
+  (when (= result-code Activity/RESULT_OK)
+    (cond
+     (= request-code intent-save-file)
+     (let [uri (.getData data)
+           filename (.getPath uri)]
+       (spit filename (.getText (program-source-editor @this)))
+       ;; (with-open [writer (BufferedWriter. (FileWriter. filename))]
+       ;;   (.write writer (.getText (program-source-editor @this))))
+       )
+     (= request-code intent-load-file)
+     (let [uri (.getData data)
+           file (.getPath uri)]
+       (.setText (program-source-editor @this)
+                 ^String (slurp file)))
+     :else
+     ;; ignore it
+     nil)))
+
 ;; (defn -onSaveInstanceState [^org.turtle.geometry.TurtleGraphics this
 ;;                             ^android.os.Bundle bundle]
 ;;   )

             (.setCurrentTabByTag tab-host
                                  (.getString activity
                                              (resource :string
                                                        :graphics_tab_label)))))
         (log "Clicked run button"))))

    (.setOnClickListener
     button-stop

                 (.runOnUiThread
                  activity
                  (fn []
                    (report-error activity "Interrupted" false))))
               (catch Exception e
                 (.runOnUiThread
                  activity
