# Runtime Save & Load

You can find the save/load settings in the Databrain editor.

<div align="left"><figure><img src="/files/mjHG5N9Zuw7Lyil8ofY7" alt=""><figcaption></figcaption></figure></div>

To serialize your data to a Json file, you can simply call the Save method on the DataLibrary object and pass a path including save file as parameter. The same goes for loading the data back. Please see the following example code:

```csharp
public class SaveLoadManager : MonoBehaviour
{
    public DataLibrary data;
    public string filename = "savegame.json";
    
    void Start()
    {
        data.RegisterInitializationCallback(Ready);
    }
    
    void Ready()
    {
        data.OnLoaded += DataLoaded;
        data.OnSaved += DataSaved;
    }
    
    // Call this method to save the data
    public void Save()
    {
        // Create save path
        var path = System.IO.Path.Combine(Application.persistentDataPath, filename);
        // Save data
         data.Save(path);   
    }
    
    // Call this method to load data back
    public void Load()
    {
        // Create save path
        var path = System.IO.Path.Combine(Application.persistentDataPath, filename);
        // Load data
        data.Load(path);
    }
    
    // Called after data has been loaded
    void DataLoaded()
    {
        Debug.Log("Data loaded");
        
        // Do something with it
    }
    
    // Called after data has been saved
    void DataSaved()
    {
        Debug.Log("Data saved");
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://giantgrey.gitbook.io/databrain/guides/runtime-save-and-load.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
