I see several examples here, but none speak to backing up SQLite databases specifically, does anyone have a sample of doing this?
http://www.microdu.com/docs/guide/topics/data/backup.html
You may want to try this question which gives an answer on how to backup your SQLite database so that it will be restored if someone installs it on a new phone (using Google's BackupAgent).
On the other hand, if you want to backup the database yourself, then you could copy it to your SD card as seen done in this question.
Related
I've been searching a way to implement SQLCipher on my prepopulated database containing more than a million entries. Last three months is the time I've fully devoted to my project's database and it's now complete which led me to a problem.
My app's database is something that I know will be copied in a week or so and copying database is so easy (just open the apk with WinRAR). And in India, No one cares about copyrights so that'll be of no use.
Basically I want to protect my app's database from copying keeping in mind that app should work offline (that being said no PHP/SQL servers).
I've checked GitHub/Google for it and only thing I've found is SQLCipher by Zetetic. Very same thing on GitHub - Here.
Also, One can import following library now: net.zetetic:android-database-sqlcipher:3.5.2#aar and can use this for securing database but it's something works on databases created by app and not on prepopulated. (lib taken from this answer on SO).
-> Now, for me the million dollar question is Is there anyway by which I can either password protect or encrypt my database without putting the database on any server?
P.S. -> I want to make my app work offline and also, I'm just a student and at least for now, can't afford Zetetic's paid service.
Edit - I've gone through codes of some google apps storing databases for some help but they are just using .out files (easily openable with Word/Text editor) compressed in .gz files which is not something I should use.
implement SQLCipher on my prepopulated database
This is pointless. Anyone who wants to can grab the encrypted database, grab the encryption key out of your app, and decrypt the database.
I want to protect my app's database from copying
Don't put it on the device.
keeping in mind that app should work offline
Depending on the nature of your app, you might be able to cache bits of data for offline use, for reduced functionality while offline.
A simpler solution is to not worry about the fact that the database may be copied. To paraphrase Tim O'Reilly, your problem is not security but obscurity.
I'm really new to programming apps - so this question might sound a bit strange:
I'm trying to program an app in android studio, where people can upload different things (basically strings and links put together in some kind of "package") and other peoble can then decide what "packages" they want to add inside their app. However after downloading, this data should be stored on their device and not just in the memory of the phone so that they can use it after restarting the app (and also if theres no internet connection). Do you have any idea what would be the best way to store this data both on the phone and in a database and how to synchronize the data on the phone with the selected data from the database. I really dont want to know how to do this exactly but would rather like some basic ideas and maybe you could tell me what kinds of stuff i should learn in order to succeed and what kind of database would be best here (firebase, MYSQL,..)?
Thanks a lot,
Andi
First of all you should decide what DB you are going to use.
In my opinion all RDBMs are good, but using Sqlite in order to achieve best performance on android devices is a good idea.
In your case you need server-side DB and application too.
(Depend on the scenario and framework you use can be different (sql,mysql,PostgreSQL,oracle,...)).
About how to sync local database with server-side you can download new DB from server and replace it with previous one, if you need previous user data you can have 2 different table and update one by downloading it from server, and save id or any identical row from specific package that already saved by user.
These are some question has been already answered in Stackoverflow
java - How to update table in sqlite?
java - SQLite in Android How to update a specific row
Create SQLite database in android
If you are talking about local databases. Go for Realm or look up a good ORM on github (Object relational mapping, you dont have to write SQL queries explicitly) .
I would suggest Realm which is very fast and user friendly.
I want to make database backup to my app, so I'm looking for the best way.
I should save a copy of the database and programatically make the backup?
Can make database backup with backup manager?
Any tips?
If you are going just to let the user save current state of the application for some reasons, db file(s) copying will be fine. Your can find plenty of samples here, like this: https://stackoverflow.com/a/2251647/812046
But if you need to restore your data on another devices, you should think of anything like sqlite .dump and you'll have to implement it yourself. As I know if you don't have root you will not be able to use native sqlite dump.
Once I used simple csv files to copy data between android device and openbsd machine. Worked fine for small amounts of data.
Hello everyone first of all.
I am making an application for android, which I need to have a database for information.
The database management computer mailbox.
What I need is to take that database and included in the application for android'S SELECT generally.
I've been testing it on this website, but I can not get it to work. I do not think either the DB copy to memory, and then to perform the query, she says she can not find the table.
I have been debugged and saw that even the open works, but something strange happens ...
If you have some method or way of doing this, I would really appreciate it.
Thanks for everything.
Check out these resources
This tutorial by Lars Vogel
This reference article from Android website
Puit it in your assets directory in your apk, and on first use copy to "/data/data/YOUR_PACKAGE/databases/" directory. Here is SO discussion on this topic. database in assets folder
EDIT: Assume a rooted phone for this post.
I deleted a previous question I posted on this topic because none of the answers even came close to answering the question. Long story short, I need to open a database and modify an existing record. I do not want to use a "helper class" because I actually want to see and understand what is going on in a few lines of code rather than an unnecessary (for my purposes) class that contains 100 lines of code. So please don't tell me to "use the notepad tutorial." I have, and it doesn't explain what I need.
To simplify, here is what I am doing:
SQLiteDatabase myDB = this.openOrCreateDatabase("/data/data/MY_APP/databases/settings.db", MODE_PRIVATE, null);
myDB.execSQL("INSERT INTO my_table (SOME_FIELD) VALUES ('SOME_VALUE');");
This works very nicely. However it fails if I try to open/edit a database in a different path. For example I might want to edit a database that another app uses. How can I do this? Is it a simple matter of permissions? Should it work if my app requests and gets root access?
EDIT: There are tons of apps I can install on my phone that are capable of editing every single database on the system so obviously this CAN be done.
Regarding Android security, you cannot access others' app DB directly. If other applications create ContentProvider then you can access theirs DBs (if exist) through its Providers. Otherwise, there's no way out AFAIK.
I don't know if you are still looking for this answer. I was looking to do the same but couldn't really find anything. I knew I needed to use root for the process, but again, couldn't find anything. I started messing around and just trying a lot of random things, and finally found a way to do it.
The short version that worked for me is you need to, as root, change the permissions of the database, access it directly (not through an sqlite helper), do whatever you wish, and then put the permissions back. I detail all of this on my blog:
http://rratmansky.wordpress.com/?p=259&preview=true