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 8791561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:51:36+00:00 2026-06-13T22:51:36+00:00

I am writing an SDK for Android that will be used by many different

  • 0

I am writing an SDK for Android that will be used by many different apps. Each app needs to know if there is a previous installation of another app that uses the SDK; the first one will create a random id (a cookie) and store it, all later apps have to read it and reuse it. Note that the cookie will be created anew for every device.

I have searched for a long time for the answer; please read thoroughly before answering because I have read lots of different StackOverflow answers and have scoured the internet reading random blogs; I have tried a lot of things but none worked (I will save you the links).

  • A ContentProvider is definitely overkill. Also it needs to intrude an app’s AndroidManifest.xml, something I am trying to avoid.
  • Likewise for a service: needs to be defined in the AndroidManifest.xml, which I do not control and do not want to require changes to.
  • Using external storage would perhaps be an option, but I don’t want to require additional permissions.
  • Using SharedPreferences directly with getSharedPreferences() does not work because apps can only access their own preferences.
  • I can get a common preferences object using createPackageContext(package, MODE).getSharedPreferences(). This would work beautifully if I had a main package and many clients of the data, but in fact I don’t know the package of the app that will be installed first — it can be any of them. I don’t even have a list of package names to search. Passing a package name which has not been installed fails.
  • Following the approach above, I have tried to piggyback on some standard Android app which I can count on, and store my preferences there — say:

    createPackageContext(
        "com.android.browser",
        Context.CONTEXT_RESTRICTED)
        .getSharedPreferences(
            "GLOBAL_PREFS",
            Context.MODE_WORLD_READABLE);
    

    but it does not work: the error reads

    Couldn't create directory for SharedPreferences file
      /data/data/com.android.browser/shared_prefs/GLOBAL_PREFS.xml
    

So, to recap: I need to store a piece of data (a short string) in some standard location, so that any other app can go there and read it if present, and it should work if at all possible without doing any magic in the AndroidManifest.xml or requesting any permissions.

There probably isn’t any perfect answer, so perhaps the best solution is to write to external storage; then so be it. To put things into context, apparently it is trivial to do this on iOS using a keychain, designed to store secure data.

  • 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-06-13T22:51:37+00:00Added an answer on June 13, 2026 at 10:51 pm

    Unfortunately there really isn’t a great answer for this that I know of. You’ve come up with a pretty good outline of your options and the best way may well be with external storage.

    Just to throw something out there, I suppose it’s possible you could use a flat file with a fixed name and world readable (and possibly writable) permissions. You’d have to then iterate through all applications’ directories and check for this known-named file in each folder and attempt to open it.

    While this might work theoretically, consider the case where the app that contains the “cookie” is uninstalled. Then you’re left cookie-less. You might want to create the cookie in every app, copying over the value of the previous cookies to new cookies.

    I haven’t actually tried this, but I imagine it should work.

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

Sidebar

Related Questions

I am considering writing an Android app, and I see that the SDK is
I'm writing a toy car-navigation app for Android, mostly to learn the Android SDK.
I was writing an Android app for Android SDK 2.3.3 but then I was
I am writing an Android app that connects to a Bluetooth device, reads data
when writing my android app i used android:background=?android:attr/selectableItemBackground I tried looking for attr.xml file
I started writing my first Android app, and chose SDK 2.0.1, before I had
I am writing an application that SDK 10+. I would like all of my
I'm toying with the Android SDK, with a view to writting a simple app
I am writing a RTSP client in Android for streaming video using Android SDK.
My Android app is reading and writing to a local SQLite DB from a

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.