0

Possible Duplicate:
Backup and restore SQLite database to sdcard

I'm writing an application and I need to be able to backup a database to the sdcard and restore it via java. I first tried just copying it to the sdcard that seems to work fine and after browsing the database it seems to be all there and fine. However i can not seem to restore it if i just copy it back and overwrite the existing one i get force closes. I'm looking to backup the sms database and restore it. Thank you for any help with this issue

Community
  • 1
  • 1
user577732
  • 3,956
  • 11
  • 55
  • 76
  • Are you sure you havn't made any locks on the database when trying to overwrite it? – H9kDroid Nov 13 '11 at 01:35
  • I dunno i haven't touched the database i just did like with bash at first cp the sms database from /data/data/com.android.providers.telephony/databases/smsmms.db to the sd and then i just tried copying it back and the sms app force closes then – user577732 Nov 13 '11 at 02:15
  • anyone got any solutions to my problem? – user577732 Nov 14 '11 at 02:59
  • http://stackoverflow.com/questions/2170031/backup-and-restore-sqlite-database-to-sdcard - This can be useful to you. – Praveenkumar Dec 05 '11 at 13:48

1 Answers1

0

Did you make sure to set file permissions back so the sms app has permissions to read the file?

Files stored on sdcard all have ---rwxr-x, so copying your backed up sms database to /data/data/com.android.providers.telephony/databases/ will keep those permissions from sdcard, also if you are copying it as root, root will be the owner of the file, denying the sms app write privileges i believe

-rw-rw---- radio radio 972800 2011-12-05 06:40 mmssms.db

there's the db on my device, so after you copy your backup back onto device /data/data do

chmod 660 mmssms.db

and change the ownership back to radio

chown radio.radio mmssms.db

mih
  • 515
  • 3
  • 13