how to save data on cellphone unity android

 using System.IO  public class scoreFile {     private int[] level;     private bool[] completed;     private float[] completionTime;      private string[] scores;      private string fileName;       //This class stores information for each of the levels.     public scoreFile(int num)     {         fileName = "scores.txt";          try         {              if (!File.Exists(fileName))             {                  level = new int[num];                 completionTime = new float[num];                 completed = new bool[num];                 scores = new string[num];                  Debug.Log("Opened file!");                  for (int i = 0; i < num; i++)                 {                     level[i] = i + 1;                     completionTime[i] = 0;                     completed[i] = false;                      scores[i] = level[i] + " " + 0 + " " + completionTime[i];                 }                  Debug.Log("About to write into file!");                 File.WriteAllLines(fileName, scores);             }              else             {                 Debug.Log("File is exist! Loading!");                 loadFile();             }         }          catch (System.Exception e)         {             Debug.Log(e);         }     }      public bool isComplete(int i) { return completed[i]; }     public int levels(int i) { return level[i - 1] + 1; }     public float timeScore(int i) { return completionTime[i]; }        public void loadFile()     {         Debug.Log("Reading");         string[] levelsInfo = File.ReadAllLines(fileName);          int num = levelsInfo.Length;          level = new int[num];         completionTime = new float[num];         completed = new bool[num];          for (int i = 0; i < num; i++)         {             //Debug.Log(levelsInfo[i]);             string str = levelsInfo[i];             level[i] = (int)int.Parse(str.Substring(0, 1));             int f = int.Parse(str.Substring(2, 1));             if (f == 0)                 completed[i] = false;             else                 completed[i] = true;             completionTime[i] = (float)float.Parse(str.Substring(4));         }     } }

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source