DEV Community

Cover image for SharedPreferences Debugging: Unlocking the Developer Mode with Prefixer
Vishal Gaur
Vishal Gaur

Posted on • Originally published at Medium

SharedPreferences Debugging: Unlocking the Developer Mode with Prefixer

Hello, my amazing cohort of Android developers!

Do you remember the last time you were neck-deep in debugging, wishing there was a way to just peek into your app's SharedPreferences without plugging into the matrix of your development setup? Oh, what you wouldn't have given to simply tap your phone and instantly see what mischief current_visit_count is up to or if remember_me is really remembering you. πŸ’‘ Well, now there's an Android library called Prefixer.

✨ What's Prefixer?

Prefixer takes the pain out of SharedPreferences debugging. I'm talking about the kind of ease and capability to change shared preferences – all from the comfort of your Android device. No more chains tying you to your system, no more elaborate rituals to simply check if a boolean is true or false. Just you, your app, and a seamless bridge to your SharedPreferences.

All Preferences Activity Edit Boolean Preferences Edit String/Number Prefs
Preferences View. Edit Boolean Preferences Edit String/Number/Floats Preferences.

πŸš€ Features That Spark Joy

  • Device Direct Access: Forget about the cumbersome tether to your development machine. With Prefixer, your SharedPreferences are accessible right on your device, providing you the freedom to debug on the fly.
  • Simple Yet Powerful: Launch a dedicated activity to display all stored preferences with a couple of taps, and jump into editing mode with a long press. It's like having a secret dashboard for your app's inner workings.
  • Developer Zen: This library is all about bringing peace to your development chaos, enabling you to focus on crafting fantastic experiences for your users, not wrestling with SharedPreferences.

πŸ›  The One Key Use Case That Changes Everything

Imagine you're out grabbing coffee, away from the safe harbour of your development setup, when you get an epiphany or need to squash a particularly sneaky bug. It could involve checking if current_visit_count is counting correctly or verifying the state of remember_me. Normally, you'd sigh, thinking of the debugging odyssey awaiting you back at your desk.

Enter Prefixer. πŸ§™β€β™‚οΈ

With this library, the only thing you need is your Android device and a few taps. Launch the Prefixer activity within your app, and you're greeted with all your SharedPreferences laid out before your eyes. Need to make a change? Long press, edit, and boom – you're done. No cables, no laptops, just you saving the day, one SharedPreferences at a time.

🌟 Getting Started

Ready to embrace your new debugging superpowers? Here's how to get started:

Step 1: Let The Magic In

Add the glittering dust of Prefixer to your app by popping this into your module's build.gradle:

dependencies {
    implementation 'dev.vishalgaur:prefixer:1.2.0'
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Wake the Wizard Within

Make Prefixer come alive with a simple incantation in your Activity or Fragment:

val prefixerInstance = Prefixer.initialize(applicationContext, "your_pref_file_name")
Enter fullscreen mode Exit fullscreen mode

Just replace "your_pref_file_name" with your own or summon the default SharedPreferences with null.

Step 3: Open the Gates

Whenever you feel the need to consult the oracles (a.k.a. check your SharedPreferences), just do:

val launchIntent = prefixerInstance.getLaunchIntent(context);
startActivity(launchIntent)
Enter fullscreen mode Exit fullscreen mode

And just like that, you're in.

πŸŽ‰ Wrap Up: Join the Fellowship

Adding Prefixer to your development toolkit is like forming a fellowship with other developers who've chosen the path of ease and efficiency. It’s not just about the convenience; it’s about transforming the way we approach SharedPreferences debugging β€” together.

Check out the spellbook (a.k.a. the GitHub repo - Prefixer) for more details. Give a star, if you feel this can be helpful and can be improved more. Contributions, feedback, or magical insights are always welcome. After all, the strength of the fellowship lies in its members.
Happy coding, my fellow wizards! May your SharedPreferences always behave, and your debugging be as enchanting as ever.


Remember, in the grand adventure of coding, tools like Prefixer are your trusty companions, helping you navigate through the forests of development with a bit more ease and a lot less stress. Let's keep crafting spellbinding apps, shall we?

Top comments (0)