1

I am trying to create a SQLite database file for iOS and Android. However, I am running into an issue I have, so far, not been able to solve.

Point is, I know how to create a SQLite database on both devices, and I know how to do it in PHP, but somehow they cannot read each-others databases.

How I create/open the sqlite file in php:

$dbhandle = sqlite_open('icddb.sqlite', 0777, $error);

I do queries like this:

sqlite_exec($dbhandle,$query);

When I put the filled database to iOS, this message is displayed:

file is encrypted or is not a database

How can this be solved? I have same problem when I create the SQLite file with firefox plugin 'SQLite Manager'

Note: PHP is in any case able to open the SQLite file.

Edit:

Apparently the latest stable PHP version creates a SQLite v2 file instead of a v3, which is used by all other. This probably is also my fix.

Rene Pot
  • 24,681
  • 7
  • 68
  • 92
  • I think this is a permission problem for the db user on the mobile systems. Make sure the user has read/write permissions directory where the SQLite DB is. – Phill Pafford Oct 10 '11 at 14:54
  • that's what I thought too. So I just set permission for all to read & write, but still no result. Still same error. – Rene Pot Oct 10 '11 at 15:09
  • so on the Android device can you see who the owner is of the SQLite DB? Same for you iOS device and same where your locale install. Just for clarity when you say "You set the permissions to all read & write" would that translate to 777 permission? Also is this on the DB itself of the directory? – Phill Pafford Oct 10 '11 at 15:14
  • 777 on both the file & directory. – Rene Pot Oct 10 '11 at 15:17
  • This might be your problem: http://stackoverflow.com/questions/1513849/error-file-is-encrypted-or-is-not-a-database – Phill Pafford Oct 10 '11 at 15:20
  • Alright, awesome @PhillPafford. That is indeed my problem. I also just edited my question with the same outcome! (could you create an answer for it so I can mark it as best)? – Rene Pot Oct 10 '11 at 15:21

2 Answers2

1

This is a SQLite version mismatch problem, Related Link:

Community
  • 1
  • 1
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
0

Probably they use different SQLite implementations or something similar.

Run a script that outputs the contents you want to send (for example, output the data in JSON)

Then parse the contents on the other side.

Pedro Loureiro
  • 11,436
  • 2
  • 31
  • 37
  • Thanks for suggestion, but the data is about 4MB, and parsing it in iOS is no issue, but Android is having memory issues. Also, I am maintaining the data in PHP, so parsing the SQLite file would be much easier – Rene Pot Oct 10 '11 at 15:11
  • I had a similar issue (file too big) and splitting it into a few chunks solved the problem. Maybe you could split your data? – Pedro Loureiro Oct 10 '11 at 15:14