I am Working on an Android Application which will be launched with a huge Pre loaded SQLite database. Problem is that database is visible to Applications like HACKDataApp etc. And Can also be viewed and copied in Android Device Monitor.
Question is, Is there any way to protect\hide my database from other applications??
you got to make your contentProvider not exported. SImply as that :
from official documentation :
android:exported: Flag allowing other applications to use this provider.
put this in your manifest declaration for each contentProvider.
Related
Is it possible to update SQLite database of android app outside app?I mean can user modify database according to them where the database situates in default location?
The default location is in /data/data/your-package/databases which is only accessible from your application. No other application is able to access it.
However in some special cases like rooted device, debug mode etc , it is still possible to access the database file and change it.
You can access the DB using Content Provider if you want to access it programmatically. Or If you just want to browse the data then you can follow this post.
i have one application with SQLite database and then i create another application that can connect to the database that i created one, my question is, is it possible connect the existing database without copying the existing once ? if possible can any one give me a sample code to connect my existing database . the name of my database is "SEIS" and the Table is Proinfo .
By default, each app's files are private to the app.
You could tell Android that your two apps should get permission to access each other's files by setting the sharedUserId attribute for both and signing them with the same signature, but the 'official' way to give other apps access to your data is to create a content provider.
Yes it is possible through the use of content providers. According to the documentation:
A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider client object.
I suggest you read the following articles:
http://developer.android.com/guide/topics/providers/content-providers.html
http://www.tutorialspoint.com/android/android_content_providers.htm
I am trying to implement a service to backup the SQLite database of my Android app. I am planning to both schedule this service for frequent backups (every day for example), and add an option to launch it immediately.
My problem is that the service might start while the application is running, or the user might start the application while the backup is in progress. And they may write to the database while I am copying it.
Is there any way to make sure that the copy and write will not run concurrently, without adding synchronization locks to all my queries ?
Thanks !
If you are not using explicit transactions, SQLite will automatically use a transaction around each SQL statement.
To ensure that the database files cannot be accessed by another database connection while you are doing the backup, open an exclusive transaction around the backup.
SQLite site has some notes on doing hot backup on a running database. See the Example 2 in that page.
In android, if you want to initiate a file copy of your sqlite db file, you will first need to get a shared lock as mentioned above, but this approach has shortcomings.
Ideally, you would want to use the sqlite3_backup_* apis.
These APIs are not available in standard android sqlite API, but it is easy to copy the sqlite jni code to your project, and expose these additional features. The advantage with this approach is that you dont have to change existing API calls in your code, as it mirrors existing android sqlite API definitions.
To expose backup APIs, take a look at android_database_SQLiteConnection.cpp to see how existing JNI functions call the native sqlite_* APIs.
Another option is to use something like sqlite4java, it has the sqlite backup APIs wrapped in as Java APIs, and seems the latest version supports Android.
I want to implement an Android app which can monitor another specific app's sqlite database, and remove some specific rows from a table. The working senaria is as below:
Open a specific social app (for example, twitter), and press
Refresh/LoadMore
The social app sends HTTP request to retrieve
data
The social app parses the result, and insert into sqlite
database
[My App] My app monitors the table changes, and update
some rows
The social app displays records from sqlite to UI (The
rows that my app removes will not be displayed in UI).
Is it possible to develop such kind of app? I understand this app needs root access. But if the app has root access, can I achieve this goal? Thanks.
this is only done when other app have used ContentProvider and the give us Permission for access that.
A ContentProvider can be used internally in an application to access data. If the data should be shared with another application a ContentProvider allows this.
Many Android datasources, e.g. the contacts, are accessible via ContentProviders. Typically the implementing classes for a ContentProviders provide public constants for the URIs.
for more detail check this artical and this two artical from Adnroid Developer one and two
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.