DEV Community

Cover image for 🚀 Shared Preferences API for Java 🚀
omega ui
omega ui

Posted on • Edited on

1

🚀 Shared Preferences API for Java 🚀

Hello, world!
This tiny API is worth taking a look.

Features

  • 📢 No Redundancy
  • 😼 Easily Handles multiple references of same Storage
  • 🤖 Real-Time Write i.e Automatically Saves file on changes
  • 🎉 Auto constructs the entire path
  • 🚀 Usable with Java CLI and any GUI framework

Example:


public class Preferences {
    public static void save(){
        HashMap<String, Integer> map = new HashMap<>();
        map.put("Simon", 99);
        map.put("Alex", 96);
        map.put("Sofia", 89);

        DataStorage storage = DataStorage.getStorage(".config", "settings.json");
        storage.put("students", map); // Auto-Save

        System.out.println(storage.query("students", "Simon"));
        // Displays 99


        DataStorage storage2 = DataStorage.getStorage(".config", "settings.json");
        storage2.put("teachers", 18); // Auto-Save
        // storage2 is the same storage object with no object redundancy 😎

    }

    public static void main(String[] args) {
        save();
    }
}

Enter fullscreen mode Exit fullscreen mode

Visit Repo

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay