Pref Editor: How to Modify Android Preferences in Real-Time During Development

Charles MucheneCharles Muchene
8 min read

The Android Developer's Preference Testing Nightmare

How many times have you been in this situation? You're developing an Android app, need to test different preference values, and find yourself stuck in this frustrating cycle ๐Ÿ˜ข:

  1. Change a preference value in code

  2. Build the app (wait 30+ seconds)

  3. Install on device (wait another 15 seconds)

  4. Navigate to the screen to test

  5. Realize you need a different value

  6. Repeat the entire process

If you're nodding your head, you're not alone. This workflow wastes hours of development time every week. Whether you're working with legacy SharedPreferences or the modern Preferences DataStore, testing different preference configurations shouldn't require constant app rebuilds.

Enter Pref Editor โ€“ a game-changing tool that lets you view and modify Android app preferences directly on your device in real-time, without root access.

What is Pref Editor?

Pref Editor is a developer tool that provides instant access to your Android app's preference files during development. It works with both:

  • SharedPreferences (legacy preference storage)

  • Preferences DataStore (modern preference storage)

The Old Way vs. The New Way

Traditional Workflow:

  • Edit code โ†’ Build โ†’ Install โ†’ Test

  • 2-5 minutes per change

  • Lost context switching

  • Multiple APK builds required

With Pref Editor:

  • Edit preference โ†’ Test immediately

  • 5-10 seconds per change

  • Stay in testing flow

  • Zero rebuilds needed

Key Features That Save Development Time

โœ… No Root Required

Works on any Android device with USB debugging enabled โ€“ no need to root your test devices.

โœ… Real-Time Editing

Changes take effect immediately without app restarts in most cases.

โœ… Type Safety

Built-in validation prevents you from saving incompatible data types (e.g., string in an integer field).

โœ… Rollback Protection

Every edit can be backed up automatically to enable reverting the changes if necessary (desktop version only).

โœ… AI-Powered Natural Language Control

Use plain English commands like "Toggle the dark mode preference" or "Set user level to 5".

Two Powerful Versions to Choose From

Pref Editor comes in two variants designed for different development workflows:

1. Desktop Application (GUI)

Perfect for visual preference management and team members who prefer graphical interfaces.

Best for:

  • Developers who prefer visual interfaces

  • Team members less comfortable with command-line tools

  • Complex preference debugging sessions

2. MCP Server (AI-Powered)

Ideal for developers who want to integrate preference editing into their AI-assisted workflow.

Best for:

  • Developers using GitHub Copilot or Claude

  • Teams adopting AI-driven development workflows

  • Quick preference changes without leaving the IDE

  • Natural language preference management


Getting Started: Desktop Application

Prerequisites

  • Android device with USB debugging enabled

  • ADB (Android Debug Bridge) installed

  • Java 17 or higher

Installation & Setup

  1. Download the Desktop App

    https://github.com/charlesmuchene/pref-editor-desktop/releases/latest

  2. Enable USB Debugging

    • Go to Settings โ†’ About Phone

    • Tap "Build Number" 7 times to enable Developer Options

    • Go to Settings โ†’ Developer Options

    • Enable "USB Debugging"

  3. Connect Your Device

     # Verify ADB connection
     adb devices
     # Should show your device as "device" (not "unauthorized")
    

Basic Usage Walkthrough

Step 1: Launch and Select Device

  • Launch Pref Editor Desktop

  • Your connected devices appear in the listing

  • Select/filter your target device

Step 2: Choose Your App

  • Browse/filter installed applications

  • Search by package name or app name

  • Select the app whose preferences you want to edit

Step 3: Select Preference File

Common preference file names include:

  • shared_prefs/[package_name]_preferences.xml

  • shared_prefs/user_settings.xml

  • files/datastore/app_config.preferences_pb

Step 4: Edit Preferences

  • View all preference key-value pairs

  • Edit any value inline

  • Changes are validated by data type

  • Click "Save" to apply changes immediately

Real-World Example: Testing User Onboarding

<!-- Before: User hasn't completed onboarding -->
<boolean name="onboarding_completed" value="false" />
<integer name="onboarding_step" value="0" />
<string name="user_level" value="beginner" />

<!-- After: Simulate experienced user -->
<boolean name="onboarding_completed" value="true" />
<integer name="onboarding_step" value="5" />
<string name="user_level" value="expert" />

Result: Instantly test your app's behavior for users at different onboarding stages without creating multiple test accounts or rebuilding.


Getting Started: MCP Server (AI-Powered)

The MCP (Model Context Protocol) server brings AI-powered preference editing directly to your IDE. Use natural language to modify preferences while coding.

There are plans to re-implement this using ddmlib to take advantage of pre-installed JVM toolchain.

Prerequisites

  • Node.js 16+ or npx (or use docker image)

  • Android Studio with GitHub Copilot plugin

  • OR Claude Desktop

  • OR VS Code with compatible AI extension

Android Studio Setup

  1. Install the MCP Server

     npm install -g @charlesmuchene/pref-editor-mcp-server
    
     // OR
    
     docker pull charlesmuchene/pref-editor-mcp-server
    
  2. Configure GitHub Copilot

    • Open Android Studio

    • Click the "Agent mode" tab in Copilot

    • Click "Add tools" button

    • Click "Add More tools..." (opens mcp.json file)

  3. Add Server Configuration

     {
       "servers": {
         "pref-editor-mcp-server": {
           "type": "stdio",
           "command": "npx", // or docker
           "args": ["@charlesmuchene/pref-editor-mcp-server"]
         }
       }
     }
    

Natural Language Commands You Can Use

// Toggle boolean preferences
"Toggle the dark mode setting"
"Enable notifications for this user"
"Turn off the tutorial flag"

// Update numeric values  
"Set the user level to 10"
"Increase the retry count by 5"
"Change the timeout to 30 seconds"

// Modify string preferences
"Update the username to 'testuser123'"
"Set the API endpoint to staging"
"Change the theme to 'material_dark'"

// Add new preferences
"Add a new preference called 'feature_flag_enabled' with value true"
"Create a timestamp preference with the current epoch time"

Example AI Workflow

Developer: "I need to test the premium user experience"
AI + Pref Editor: 
โœ… Set user_subscription_status to "premium"
โœ… Set subscription_expiry to future date
โœ… Enable all premium features
โœ… Update user tier to "gold"

Developer: "Now test the expired subscription flow"  
AI + Pref Editor:
โœ… Set subscription_expiry to past date
โœ… Set user_subscription_status to "expired"
โœ… Disable premium features
โœ… Add grace_period_days with value 7

Common Use Cases and Time Savings

1. Feature Flag Testing

Before: Rebuild app for each feature flag combination (5 minutes per test)

After: Toggle flags instantly (10 seconds per test)

Time Saved: 4+ minutes per test ร— 10 tests = 40+ minutes daily

2. User State Simulation

Before: Create multiple user accounts or reset app data

After: Modify user preferences directly

Time Saved: 2-3 minutes per user state test

3. API Environment Switching

Before: Change code, rebuild, test each environment

After: Switch API endpoints via preferences

Time Saved: 3-5 minutes per environment switch

4. Onboarding Flow Testing

Before: Clear app data and repeat onboarding

After: Set completion flags and test any step

Time Saved: 5+ minutes per onboarding test

Troubleshooting Common Issues

Device Not Detected

# Check ADB connection
adb devices

# If "unauthorized", check device screen for USB debugging dialog  
# If no devices, try:
adb kill-server
adb start-server

Permission Denied Errors

# Ensure USB debugging is enabled
# Try different USB cable (data cable, not charge-only)
# Enable "Disable adb authorization timeout" in Developer Options

App Not Listed

# App must be installed on device
# Some system apps may be filtered out
# Try searching by exact package name

Preferences Not Updating

# Some apps cache preferences - try force-stopping the app
# Verify the correct preference file is selected
# Check if app is using DataStore vs SharedPreferences

Which Version Should You Choose?

Choose Desktop App if:

  • โœ… You prefer visual interfaces

  • โœ… You frequently do complex preference debugging

Choose MCP Server if:

  • โœ… You use AI coding assistants (Copilot, Claude, etc.)

  • โœ… You want to stay in your IDE while testing

  • โœ… You prefer command-line/text-based workflows

Why Not Both?

Many developers use both versions:

  • MCP Server for quick changes during active development

  • Desktop App for detailed debugging sessions and team collaboration


Performance Impact and Best Practices

Performance Considerations

  • Minimal Impact: Reading preferences has negligible performance overhead

  • Safe Editing: Type validation prevents crashes from invalid data

  • Non-Intrusive: No code changes required in your app

Best Practices

  1. Backup Important States: Use the automatic backup feature (only on GUI version) before major changes

  2. Test Edge Cases: Try invalid values to ensure your app handles them gracefully

  3. Document Configurations: Save useful preference combinations as presets

  4. Team Standards: Establish naming conventions for shared preference configurations


Conclusion: Reclaim Your Development Time

Developer time is precious, and every minute spent waiting for builds is a minute not spent solving real problems. Pref Editor transforms Android preference testing from a time-consuming bottleneck into an instant, seamless process.

What You Gain:

  • 2-5 minutes saved per preference change (that's hours per week for most developers)

  • Faster iteration cycles leading to better-tested features

  • Reduced context switching and improved focus

  • Enhanced debugging capabilities for preference-related issues

  • Better collaboration between developers and QA teams

Getting Started Today:

  1. For GUI lovers: Download Pref Editor Desktop

  2. For AI enthusiasts: Install Pref Editor MCP Server

  3. For teams: Try both and see which fits your workflow better

The future of Android development is about removing friction and focusing on what matters: building great user experiences. Pref Editor is your first step toward a more efficient, enjoyable development process.

Ready to revolutionize your Android preference workflow? Try Pref Editor today and join the developers who've already reclaimed hours of their development time each week.

Happy Androiding! ๐Ÿ˜Ž


Additional Resources

0
Subscribe to my newsletter

Read articles from Charles Muchene directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Charles Muchene
Charles Muchene

Software Engineer