0

I created sqlite table to store values of differnet fields as shown below.

 CREATE TABLE places_table (PlaceID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, PlaceName VARCHAR(50), PlaceAddress TEXT, PlaceLatitude REAL, PlaceLongitude REAL);

I can assign some value to PlaceLatitude and PlaceLongitude and display the values in UItable. But when I close and restart the application it displays value of these two fields as 0. Other entries (PlaceAddress, PlaceName) do not have this problem.

Can anyone please help me? Thanks for help in advance.

alekhine
  • 1,600
  • 4
  • 20
  • 45
  • Are you sure first time values are comming from DB? If so then please provide code you wrote to insert data in DB. – Mohammad Sep 03 '11 at 08:05
  • Thanks for your answer. There was error while inserting data to the sqlite database. You can post your comment as answer then I can approve it as the right answer – alekhine Sep 03 '11 at 10:27

3 Answers3

1

I think you have to check condition if table exit or not .

Narayana Rao Routhu
  • 6,303
  • 27
  • 42
  • Thanks for you response. I checked condition if table exist or not and it yielded that table exists – alekhine Sep 03 '11 at 10:10
1

Are you sure first time values are coming from DB? If so then please provide code you wrote to insert data in DB.

Mohammad
  • 1,636
  • 1
  • 13
  • 17
0

One possibility of such behavior is that you're doing writing operation in your in-bundle sqlite3 database which is read-only. To solve this, you may need to copy the in-bundle sqlite3 database to the app sandbox when user runs the app for the first time.

If this is your case, please follow this thread: Where would you place your SQLite database file in an iPhone app?

Community
  • 1
  • 1
Chris Chen
  • 5,307
  • 4
  • 45
  • 49
  • Thanks for your response. SQL database I am using is read and write type. I will definitely read link you provided. Error was while inserting the data to database. But I didn't gave details of code so it was impossible for anyone to identify cause of problem. Thanks for youe help again. – alekhine Sep 03 '11 at 10:14