Sqlite 3.8 with pre-Lollipop APIs - android

I have a pre-populated database that i'm trying to copy from assets folder.The database uses a few WITHOUT ROWID tables which according to sqlite.org work only with SQLite version 3.8.2 (or later versions).
According to this SQLite 3.8 is not supported on pre-20 APIs and on those cases i get a "malformed database schema" exception when trying to copy the database.So, is there a way to use SQLite 3.8 on older APIs?

The simplest thing, by far, is to get rid of WITHOUT ROWID.
It is possible to package an independent copy of SQLite with your app. SQLCipher for Android is one such packaging. However:
This adds a few MB to the size of your app, eliminating any savings that you are getting by avoiding ROWID
If for some reason you do not want to use SQLCipher for Android, implementing this yourself is a lot of work

Related

Can I use an sqlite database created for android in IOS

I have an Android app I wrote that uses a sqllite database,(the app is used for the reservation) now I want to write the same app for iPhone and I want to use the same database I used in Android app. My question is can I use the same database in IOS.
If yes, then how can be used and where I place the sqllite database (I mean what folder)? and the users must be online to see the update in the database ?
Can I use an sqlite database created for android in IOS?
Yes, an SQLite database is a a file (or potentially 3 files if using Write-Ahead logging). It's simply a matter of copying the file(s).
Typically (i.e. if not specifying otherwise) an SQLite database is stored in data/data/your_package/database/the_database_name
where your_package is as per the App and the_database_name is the file name (may or may not have an extension).
Note if the database uses Write-ahead logging then 2 other files may exist, these being the_database_name-wal and the_database_name-shm. If they exist and are not empty, they need to also be copied.
However,
and the users must be online to see the update in the database ?
Is a completely different matter though. SQLite is not suited to a client/server situation, as you would have to write all the code to provide this functionality. See Appropriate Uses For SQLite.
Firebase may be an option if you don't mind Google's policies reqgarding information privacy. Otherwise you are likely then looking at something like MySQL/MariaDB.

Is it possible to sync android ormlite across device?

I am considering using ORMLite for persistance in an android app. A requirement is to be able to sync the underlying android SQlite database across multiple android devices.
Is this possible with ORMLite? And how?
You can directly copy the database file over to another device and it will work if you didn't change the schema.
I wouldn't recomment that though. Instead you could load the Object tree from your db using ORMLite, copy it over, and write it back to the db with ORMLite. You might want to look into SyncAdapters too.

Light weight mechanism for encrypting sqlite database on android without shipping customized sqlite distibution

I am building one android application where I want to maintain certain details in the sqlite database. I am using SQLiteOpenHelper interface in order to maintain single instance of the database for all the threads accessing the database.
For security reasons I want to encrypt my database because if the database file is not encrypted, it is possible to view the database file on rooted android devices.
To avoid this I want to encrypt the database file.
I have gone through SEE, wxSQLite, SQLiteCrypt and botansqlite3 but they all require cutomized distribution of SQLite to be shipped onto android device.
I want to secure my database file with the normal distribution of SQLite that is shipped with Android.
Also I tried to use SQLCipher but it increases my application's total size by 8-10MB. One more reason for not using SQLCipher is that it doesn't support mips architecure (but this could be built later on with some modifications in the source code).
Also my database will be accessed and updated by many threads and will be loaded all the time by a service so decrypting database at the time of loading/opening and encrypting at the time of unloading/closing will not work for me. It should be possible to fire queries on encrypted database only or there should be some alternative solution like creating temp database, decrypting it and performing operations on it.
Can anyone suggest me a light weight solution for encrypting SQLite database on android devices?
Thanks in advance.

Android: is it safe to use a preloaded database file?

I have a huge set of data that I want to insert into the sqlite database before the user is able to do anything inside my application. Right now I have all my data stored in CSV files, then I parse those files and use DatabaseUtils.InsertHelper to do a bulk insertion, but this is taking to long to complete.
I stumbled on this tutorial some time ago and I'm wondering: is it safe to distribute a pre-generated sqlite file? Can I run into problems due to different versions of SQLite on different devices?
I'm planning to support Android 2.1 and higher.
I suppose it depends on your definition of safe. It is certainly possible as long as the database conforms to the metadata table spec Android expects, which is what that tutorial you stumbled upon is showing you. You won't have to worry about version conflicts with SQLite as that is a package built into the core platform and isn't something OEMs add to or implement anything on top of.
However, if by safe you mean "protected" you would need to take special steps to ensure that your database is not externally readable if that is a concern. If you simply place the preconstructed DB into assets/ and copy it over, anyone who can properly deconstruct an APK file can view your database data. This may or may not be an issue for you.
The best approach is to populate this data in the database, keep the database in assets & then copy it to the device ... You can follow this complete sample code here.

Android: is it safe to remote download sqlite database

I followed instructions on http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ and succesfully inserted sqlite database on android device so user doesnt have to download data to start doing somethnig. Problem is I don't know if this trick will work on all Android devices. Does anybody have any bad experience relating to version of device, version of database or something to think again about this method? Would it be a problem if user moved app on SC card?
I have used a preloaded SQLite database in my Android applications without any problems.
I don't see any reason why doing this would be incompatible with certain devices as long as your SQLite database is compatible with the version that Android ships with. Android ships with SQLite version 3.4.0 per the android.database.sqlite package description in the Android website.
Hope this helps.
I had problems with this because my database was too large for many devices. You have to either save to external storage or download your database on-the-fly. The biggest disadvantage to storing your database in the APK is that you essentially double the size of your app at runtime.

Categories

Resources