开发者

Backup/Restore database file from device to website?

开发者 https://www.devze.com 2023-03-31 16:55 出处:网络
I\'ve done a small school project to manage a library with several books, using SQLite and android 2.2. Later on, they asked me to create a back office system, which I wasn\'t ready for. So I\'m tryin

I've done a small school project to manage a library with several books, using SQLite and android 2.2. Later on, they asked me to create a back office system, which I wasn't ready for. So I'm trying to achieve a simple backup system that connects to the internet.

I would like directions or hints to:

  1. Get the project database from data/data/package_name/databases/school
  2. Send it to a online repository, could be just a ftp connection to upload school_%date% and latest.db (same contents)

and to restore:

  1. Download latest file from server, something like http://www.site.com/school/latest.db
  2. Replace data/data/package_name/databases/s开发者_如何学JAVAchool with the downloaded latest.db

I been reading about SOA and REST approaches but I couldn't implement that on the trivial server I own... any other advices? /cheers


SOA or REST would be the most pretty way to do it. The easy way is just to get the database file and send it to you webserver. But I don't know if your app has enough privileges to restore the database while running. You could use the sqlite3 commandline tool to dump an sql file, see here and send it to your webserver. Restoring would be something the same, but then you have to delete your tables first, then restore the database with the retrieved data.

Maybe it would be nice to have some version dependency management like sending your app version with the backup. This way you can administer whether a database file is compatible or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消