can you read json file on android ? I have a thesis and it's not going well.

I have these codes for my item database, it works on pc, but doesn’t work on my android phone

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitJson;
using System.IO;


public class ItemDatabase : MonoBehaviour
{
    private List<Weapon> WeaponDatabase = new List<Weapon>();
    private List<Armor> ArmorDatabase = new List<Armor>();
    private List<Potion> PotionDatabase = new List<Potion>();
    private JsonData WeaponData, ArmorData, PotionData;


    void Start()
    {
        WeaponData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/Scripts/Weapons.json"));
        ArmorData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/Scripts/Armors.json"));
        PotionData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/Scripts/Potions.json"));

        ConstructItemDatabase();

    }

    public Weapon FetchWeaponbyID(int id)
    {
        for (int i = 0; i < WeaponDatabase.Count; i++)
        {
            if (WeaponDatabase*.ID == id)*

{
return WeaponDatabase*;*
}
}
return null;
}

public Armor FetchArmorbyID(int id)
{
for (int i = 0; i < ArmorDatabase.Count; i++)
{
if (ArmorDatabase*.ID == id)*
{
return ArmorDatabase*;*
}
}
return null;
}

public Potion FetchPotionbyID(int id)
{
for (int i = 0; i < PotionDatabase.Count; i++)
{
if (PotionDatabase*.ID == id)*
{
return PotionDatabase*;*
}
}
return null;
}

void ConstructItemDatabase()
{
for (int x = 0; x < WeaponData.Count; x++)
{
WeaponDatabase.Add(new Weapon((int)WeaponData[x][“ID”], WeaponData[x][“ItemName”].ToString(),
(int)WeaponData[x][“Damage”], (bool)WeaponData[x][“Stackable”], (bool)WeaponData[x][“Equipable”],
WeaponData[x][“Slug”].ToString(), WeaponData[x][“Description”].ToString()));
}

for (int x = 0; x < ArmorData.Count; x++)
{
ArmorDatabase.Add(new Armor((int)ArmorData[x][“ID”], ArmorData[x][“ItemName”].ToString(),
(int)ArmorData[x][“MaxHealth”], (bool)ArmorData[x][“Stackable”], (bool)ArmorData[x][“Equipable”],
ArmorData[x][“Slug”].ToString(), ArmorData[x][“Description”].ToString()));
}

for (int x = 0; x < PotionData.Count; x++)
{
PotionDatabase.Add(new Potion((int)PotionData[x][“ID”], PotionData[x][“ItemName”].ToString(),
(int)PotionData[x][“HealAmount”], (bool)PotionData[x][“Stackable”], (bool)PotionData[x][“Equipable”],
PotionData[x][“Slug”].ToString(), PotionData[x][“Description”].ToString()));
}
}

public class Weapon
{
public int ID { get; set; }
public string ItemName { get; set; }
public int Damage { get; set; }
public bool Stackable { get; set; }
public bool Equipable { get; set; }
public string Description { get; set; }
public string Slug { get; set; }
public Sprite Sprite { get; set; }

public Weapon(int _id, string _itemName, int _damage, bool _stackable, bool _equipable, string _slug, string _description)
{
this.ID = _id;
this.ItemName = _itemName;
this.Stackable = _stackable;
this.Equipable = _equipable;
this.Damage = _damage;
this.Slug = _slug;
this.Description = _description;
this.Sprite = Resources.Load(“Sprites/Weapons/” + this.Slug);
}

public Weapon()
{
this.ID = -1;
}

}

public class Armor
{
public int ID { get; set; }
public string ItemName { get; set; }
public int MaxHealth { get; set; }
public bool Stackable { get; set; }
public bool Equipable { get; set; }
public string Description { get; set; }
public string Slug { get; set; }
public Sprite Sprite { get; set; }

public Armor(int _id, string _itemName, int _maxhealth, bool _stackable, bool _equipable, string _slug, string _description)
{
this.ID = _id;
this.ItemName = _itemName;
this.Stackable = _stackable;
this.Equipable = _equipable;
this.MaxHealth = _maxhealth;
this.Slug = _slug;
this.Description = _description;
this.Sprite = Resources.Load(“Sprites/Armors/” + this.Slug);
}

public Armor()
{
this.ID = -1;
}

}

public class Potion
{
public int ID { get; set; }
public string ItemName { get; set; }
public bool Stackable { get; set; }
public bool Equipable { get; set; }
public string Description { get; set; }
public string Slug { get; set; }
public int HealAmount { get; set; }
public Sprite Sprite { get; set; }

public Potion(int _id, string _itemName, int _healamount, bool _stackable, bool _equipable, string _slug, string _description)
{
this.ID = _id;
this.ItemName = _itemName;
this.Stackable = _stackable;
this.Equipable = _equipable;
this.HealAmount = _healamount;
this.Slug = _slug;
this.Description = _description;
this.Sprite = Resources.Load(“Sprites/Potions/” + this.Slug);
}

public Potion()
{
this.ID = -1;
}

}

How can I make it better, please, I need an answer. please help me.
the images for the items in the inventory are showing correctly on my pc,
but for android its null.

Hi, there is two things I can see different from our saving solution. One is that the way you save JSon file. Our solution is working fine on the Android even with encryption on top of it. You are using:

WeaponData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/Scripts/Weapons.json"));

I have not used JsonMapper.ToObject before, but this is how our code looks like:

Define the path 1st with:

 filePath = Path.Combine(Application.persistentDataPath, fileName);

Than save it using string:

string content = JsonUtility.ToJson(totalProgress, true);                 
File.WriteAllText(filePath, content);    

Maybe this method is not compatible with the Android. The other thing that I see is that you are using Application.dataPath instead of Application.persistentDataPath. Quick search returned this question: dataPath vs persistentDataPath. First one is read only. Hope that helps.