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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:58:05+00:00 2026-06-10T12:58:05+00:00

I did not find a post which ask for the same restriction as me.

  • 0

I did not find a post which ask for the same restriction as me.

I have an application which provides a content provider (call it main application) to other applications (call them client applications). I want restrict the access to the content provider from the client applications for support only the insert and maybe query methods.

What I do not want:

  • Make the content provider private because the main goal is to provide a database to client applications.
  • Restrict the access with signatures of client applications because anyone must be able to write a client application which use the main application platform.

The most obvious solution I see is to write two content provider, one with full access private of the main application, and one restricted public. But I think this is definitely not a proper way.

According to this Google groups post, I am thinking to use Binder.getCallingUid() in the content provider calls to detect if the call comes from the main application or not. So I can do nothing in update and delete methods if the call does not come from the main application.

How I can get the main application UID to compare? And if it is possible, is this solution secure?

Thanks for your advice.

  • 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-10T12:58:06+00:00Added an answer on June 10, 2026 at 12:58 pm

    Define a permission like below with protectionLevel signature, this WRITE permission will restricted to only apps which are signed with same private key

    <permission android:name="com.yourapp.WRITE.PERMISSION"
        android:protectionLevel="signature"
            android:label="@string/permission_label"
            android:description="@string/permission_desc">
    </permission>
    
    <permission android:name="com.yourapp.READ.PERMISSION"
            android:label="@string/permission_label"
            android:description="@string/permission_desc">
    </permission>
    

    Then in contentprovider tag use read and write permission tags.
    You can either enforce read permission or you could altogether remove it

    android:readPermission="com.yourapp.READ.PERMISSION"
    android:writePermission="com.yourapp.WRITE.PERMISSION"
    

    So only apps that are signed by same signature can use your content provider

    Edit:

    Maybe you could use this

     private Collection<String> getCallingPackages() {
         int caller = Binder.getCallingUid();
         if (caller == 0) {
             return null;
         }
         return Lists.newArrayList(mContext.getPackageManager().getPackagesForUid(caller));
     }
    

    And check if your packagename is present in this list. I think it is safe

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

Sidebar

Related Questions

I did not find an answer to this question. I have a VOIP application.
I have Googled merge+cell+Javascript but did not find any suitable code to implement merge
Searching did not find a similar question, so: How can POST data used by
Sorry if this is a re-post. I did not find a suitable answer. Please
I did not find any suitable questions answered yet, so I'd like to know
I did search the forum and did not find a similar question. I'm looking
I spent about hour and did not find any clue how to highlight my
I've read several sources now but did not find a solution: I'm using Facebook
So I've been looking for a good solution everywhere but did not find anything
Just for learning's sake, I tried in java doc but I did not find

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.