I developed an Android application that works on sqlite internal db.
Now I want create a new android application that clean the database of my first application.
What can I do?
Let the second application send a intent broadcast, after receiving the broadcast, let the first application can clear the data. But any application cannot clear another application's data, even if it is possible, it is not elegant.
I believe you can do it if you modify the manifest of both apps to make them share the same data directory.
Add the android:sharedUserId property to the manifest of each app.
android:sharedUserId="your.shared.id"
If they are the same and you sign them with the same key & alias, each of the appa can use/access the others private directories.
Related
I'm very new to android developing, and I'm making a project in my university for an app that backs up every other application's data to cloud. So in order to do this, I have to access it. Is it possible? And is there a way to do this without rooting the device?
The app that you want to create as backup use content provider in that app for insert,add, create, delete the data.That app work like a database for you.
For second app fetch the data from the first app.
use this link.
http://developer.android.com/guide/topics/providers/content-provider-creating.html
I have two applications which resulting to use database.
Application A which creates database name DB1. This database I wanted to access in
application B. The applications are in different packages.
How can I do this ?
Application are not allowed to read private data of another application (you can do this only on rooted devices). The easiest way is to store database in some public location, but that is not recommend because any app on device will have access to database file...
Here is what you can do. You can create BroadcastReceiver-s from both sides and implement your communication protocol using message passing. Application B will broadcast requests, application A will handle that request and send result back to the application B. The only problem is that application A code must be updated to. For more info on how to use message passing, check this article
you need to have both applications installed using same user id. Add this to both manifests:
android:sharedUserId="com.abc.xyz"
I am a new bee in android platform and creating an application.I Need to save few data in to database and shared between two application.The data I am using for licensing, so my question is Is it possible to others to copy my data base from 'data/data/pack_name/database_name' and put it into a new device?. Any suggestion will be appreciated.
I don't think it is possible for application B to copy application A data without explicit permission of application B. We have content providers specifically for the purpose of sharing data between application. But you can always try this out by creating and application and trying to access it's data from another application.
If the device is rooted then I believe it is possible for another application to copy your data.
I built an application that will download and install an APK from a WebService using the technique described here:
Install Application programmatically on Android
During this installation, the Webservice sends a 'flag' that indicates if the SQLite database from the application that is being updated should be deleted or not during it´s first run.
Is there any way to set a "Global Preference" that could be read (if the flag is true, the database should be deleted) and cleared (it should be set to false after deletion to avoid deleting the database all times that app is started) during the first usage of the updated app, without saving it to the SDCard?
I know how to read the preferences from the app that is being updated but, I did´t realize how to modify these preferences from another app.
Thanks a lot.
SharedPreferences are unique to each App/APK - no way to share them that I'm aware of and no 'Global' equivalent.
If you want to share data, the solution is usually some sort of ContentProvider, but that relies on both apps running at the same time.
If you only want to hand-over a token or state, I'd suggest writing a file onto the SDCARD is probably the simplest option?
Here is a tutorial on how to do it.
Basically you have to use MODE_WORLD_WRITEABLE for the prefs file.
To get the context for the other package you use createPackageContext()
On the dev site, it says if your applications are signed with the same certificate you can share data.
I would like to create a utility that I can pack with a csv file, sign and package the apk and when I run it on my device, I would like for that csv to be imported into another one of my apps database. Is it possible?
I know how to get the csv into a database but not how to get it into a different apps database...
You could put your database on the external sdcard. There is no security there.
For sharing protected files the applications must be signed with the same cert and have matching android:sharedUserId in their AndroidManifest.xml files.
Your utility app could try opening the other apps database with an absolute pathname. I'm not sure what would happen with transaction management if both apps are modifying the db at the same time.
A better design is to have one application only own and access the database. Implement an "IMPORT" intent handler on the app that owns the database. Your utility application can send an Intent, specifying the csv filename in the intent extraData. Or you could just put the data on the Intent's extraData (if it's large then send an Intent for each record).
The standard way is to implement a ContentProvider. Use permissions to control access.
http://developer.android.com/guide/topics/providers/content-provider-basics.html
http://developer.android.com/reference/android/content/ContentProvider.html