Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7685131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:11:03+00:00 2026-05-31T19:11:03+00:00

I got two apps, with these package names: com.blah.a com.blah.b They got the sharedUserId

  • 0

I got two apps, with these package names:

  • com.blah.a
  • com.blah.b

They got the sharedUserId “com.blah.shared”. At /data/data in my device they both got a folder with there data, which contains the shared_prefs folder and the default SharedPreferences files named:

  • com.blah.a_preferences.xml
  • com.blah.b_preferences.xml

I know that two apps with the same sharedUserId can access each others files. How can I read app a’s SharedPreferences from app b?

I found one solution, but it is neither working well (if app a updates a preference, app b still reads the old value) nor good code (can throw exception).

try {
    Context c = context.createPackageContext("com.blah.a", 
        Context.CONTEXT_IGNORE_SECURITY))

    aPrefs = PreferenceManager.getDefaultSharedPreferences(c);
} catch (NameNotFoundException e) {
}

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:11:04+00:00Added an answer on May 31, 2026 at 7:11 pm

    Generally, you shouldn’t need to do this, and sharedUserId is a bad idea for production apps. In any case, this is the code to do it, but you don’t need to specify IGNORE_SECURITY. If your apps have the same UID, they should be able to read each other’s (private) files. As for the exception, an exception will only be thrown if the package doesn’t exists. You could check if it does, and only execute the code if it exists (i.e., the other app is installed). There is probably some caching, so you should load the prefs each time you need them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got two projects running, both written in PHP. Now I want to merge
I've got two projects, one CF2.0 project and one NET2.0 project. These projects are
I have two sites in my Apps account and I've got them working for
I am new to Android development with Phonegap and just got through these two
I've been learning Android and Phonegap development from mainly these two sources: http://news.softpedia.com/news/How-to-Run-Android-Applications-on-Ubuntu-115152.shtml http://wiki.phonegap.com/w/page/30862722/phonegap-android-eclipse-quickstart
I've got two different apps that I am hosting (well the second one is
I have got two similar FB apps i am working on. The one works,
I've got two android apps, one with a public void. How would the other
I got two tables Product(Productname VARCHAR(10), Rating REAL) and Review(RatingID INT, Productname VARCHAR(10), Rating
I got two tables in my database: user and call. User exists of 3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.