I need to read a db file from a different application. The db file is created by the specific provider app & my application has to read this db file and take a back up. Not able to access the file : Permission Denied.
Is it possible to read the file created by a different app? I think it may not be possible as per the android design, but just wanted to confirm whether it is possible by setting any permission.
Thanks,
Grace.
No its not possible to read a db file from a different app in Android unless both apps are from the same publisher. It is part of the android security model that the application DB files are set as readable only by the application publisher in question.
This is done by each publisher being given their own user id on the device.
The only work rounds are
Root you android device ( If you break it you get to keep both pieces ) and run your app with elevated privs.
Look to see if the app in question has some kind of published API for querying their data.
Hope this helps
Peter
Related
By "permanent" I mean that it resists the application uninstall option that the Android OS offers. Obviously you cannot make a file not deletable in the user's terminal, at the very least, the user will always be able to delete it via the file manager if he wishes so.
I'd need this because in my app when some actions have been performed the app forbids from doing some more. So far this is controlled via a file, but there's nothing that prevents the user from uninstalling the app, and with a new fresh install this doesn't happen anymore.
I could implement some type of server-side logic to prevent the user from continueing but:
1) It's way easier to prevent just by checking the file.
2) It's not that important what happens if the user manages to bypass this security measure, so I don't really mind if a few of them are able to bypass the protection, as long as the file can be "permanent" and is in some obscure directory, not many users are going to be able to perform the mentioned behavior.
Is there any way to do this?
Just get the write file permission and write the file to the root file directory. As described here: https://developer.android.com/training/data-storage/files#WriteExternalStorage
After you request storage permissions and verify that storage is
available, you can save two different types of files:
Public files: Files that should be freely available to other apps and to the user. When the user uninstalls your app, these files should
remain available to the user. For example, photos captured by your app
or other downloaded files should be saved as public files.
Private files: Files that rightfully belong to your app and will be deleted when the user uninstalls your app. Although these files are
technically accessible by the user and other apps because they are on the external storage, they don't provide value to the user outside of your app.
this can be done by configuring auto-backup, assuming that the user has it enabled.
for example, here I've explained how to disable that behavior in debug mode.
the advance is, that it works across several devices, bound to the account.
instead of file , I would suggest to use following intent to catch uninstalling your app and put your logic to allow or deny for uninstall
ACTION_PACKAGE_REMOVED -: Broadcast Action: An existing application package has been removed from the device. The data contains the name of the package. The package that is being installed does not receive this Intent.
ACTION_PACKAGE_FULLY_REMOVED - : Broadcast Action: An existing application package has been completely removed from the device. The data contains the name of the package. This is like ACTION_PACKAGE_REMOVED, but only set when EXTRA_DATA_REMOVED is true and EXTRA_REPLACING is false of that broadcast.
I want to know how to modify message data, neither root nor default application in android application
Goal is block number list manager and i want to receive message of to filtered number I’ve looked BlockNumberContract api but this require permission like default sms/dialer application, carrier application Only default application(User is chosen application) will have access MMS-SMS ContentProvider when on android 4.4+ I was check to LINK
Also, If you know anything else, please let me know them
Additionally if impossible on android application level, Please another level any solutions and any ideas let me know
thanks :)
You can't. That's the entire reason they created the Default Messaging App- to prevent you from doing it. You need to be the default messaging app to do this- or at least root and directly edit the db.
According to Google's introduction https://developer.android.com/work/managed-profiles.html, personal files in SD cards are not accessible by work profile application. However, we can see all files in DocumentsUI(application provided by system) by click "personality" after sending Intent(ACTION_GET_CONTENT), moreover file name, size and date are shown, which seems that files are readable. But when we use the uri from onActivityResult I got FileNotException (EACCES: permission denied) if I do reading operation (READ_EXTERNAL_STORAGE permission is already granted). Can we access these personal files from a work profile applications? If yes, how can I read and write them?
Thanks in advance!
Reference question # Access SD card data from android for work app, is the answer true?
With more test, I'm able to access some video/audio/picture files from DocumentsUI(by system). But for more files provided by 3rd-party application(such as file explorer), failure still exist. I suppose that the result depends on file providers. If content uri returned with read permission granted, application in work profile is able to read.
The developer doc: Requesting Permissions at Run Time clearly mentions what runtime permission is and how to use it. And I am able to execute them as well.
However, the question is : where does Android store the run-time permission values?
ie, when the user deletes the data associated with the app, the permissions are reset, so where do Android store these values? (is it in the app cache or in any other place). And in what format ? ( is it a database or a sharedpreferences file or any other) And how are they stored? (encryped or non-encrypted) .
Searched in many existing answers and developer docs, however couldn't find any useful info in this regard. Any help will be much appreciated.
I'm not sure if you found the answer to this or not, but they are stored in:
/data/system/users/0/runtime-permissions.xml
When the system is reset, or a new user created, the system also populates this with system app permissions to auto grant them. I have been trying to research how to auto grant permissions to system apps.
See this answer for more details.
In Android 12 on Samsung phones it's:
/data/misc_de/0/apexdata/com.android.permission/runtime-permissions.xml
Can't confirm it for others.
0 seems to be the user-id.
Found by running:
find / -name '*permission*.xml' 2>/dev/null
What is the best way to discover an Android application's API or hooks into/from the application?
Specifically, I am looking to pass a parameter or data to an application, utilize the application's specific functions, and return data or a parameter to the calling application.
A few ideas come to mind, but I am unfamiliar with what is available, specifically to Android.
Contact an application's developer directly
Somehow decompile the APK to browse the source
Read any available documentation
Some ways to check out what is available for :
Tool to re-engineer closed APK files
http://code.google.com/p/android-apktool/
Review intent filters for actions
Lookup the app in some sort of application manager on your phone. Android System Info. If you go to the details of the app it will tell you where the apk is and the name of it. For instance, under the Email app you can see "Source: /system/app/Email.apk".
To pull that off just do "adb pull /system/app/Email.apk Email.apk", to pull it to your current directory.
Look at the Manifest.xml. Rename the apk to zip and unpack.
Follow the instructions here: http://android.amberfog.com/?p=582
Then you can read the decompiled Manifest.xml and look at the intent filters they are registering.
Android applications are all in their own sandbox, so you can not just arbitrarily call some other Android applications' functions, they would need to be made public to you somehow.
If you are looking to execute some function that is provided by another Android application, you would most likely need to hear about it from the developer, most likely from their public documentation if they have any.
The correct way to do this is to use "intents". With an intent, you can launch another application (such as a barcode scanner) and the user interacts with it. Then, the application exits returning some data (such as the barcode). Try googling or see:
http://www.vogella.com/articles/AndroidIntent/article.html