- Home /
Saving textarea to textfile on Android
I have a textarea where the user can enter his/her own text into. After that I have a "accept" button, if pressed, saves the textarea to a "filename".txt.
I have tried alot of different things the last days, but nothing seems to work.
This is the code I have at the moment:
 import System.IO;
 
 var tekstfelt : String = "";
 var file  : String = "Quiz name...";
 var customGUISkin : GUISkin;
 var accept : GUITexture;
 
 function OnGUI()
 {
     GUI.skin = customGUISkin;
     
     file = GUI.TextField (Rect (15, 220, 1050, 80),file, 20);
     
     tekstfelt = GUI.TextArea (Rect (15, 350, 1050, 1000),tekstfelt, 2000);
 }
 
 function Save()
 {
     for (var i = 0; i < Input.touchCount; ++i) 
     {
         var touch: Touch = Input.touches[0];
         if (Input.GetTouch(i).phase == TouchPhase.Began && accept.HitTest(touch.position))
         {
             if(!Directory.Exists (Application.persistentDataPath + "/quizes/"))
             {
                 Directory.CreateDirectory (Application.persistentDataPath + "/quizes/");
             }
             File.WriteAllText(Application.persistentDataPath + "/quizes/" + file + ".txt", tekstfelt);
             
             Application.LoadLevel ("Scene4");
         }
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to save a mesh in runtime on android 2 Answers
PlayerPrefs don't load again after Android game closes for the first time. 1 Answer
TextArea with Custom Image has no flashing indicator 0 Answers
Android/IOS: Sharing save file between free and paid versions 0 Answers
How to save my serialized levels ? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                