0

I'm trying to create an app which synchronizes with the server to populate a list.

However as I'm writing from scratch , I would want to at least populate some dummy data into it to test it out.

Should I be populating it from a dummy server or should i try to populate it with a sqlite.db file first and insert it later on from Server without creating hte table ? How are the other possible ways and which one is the best ?

jamen
  • 313
  • 7
  • 16

3 Answers3

0

Yes yon use Sqlite to populate your data in your listview. You just create a database using the Sqlite browser . download it from this link http://sourceforge.net/projects/sqlitebrowser/

Then you can use the following link to copy your database from assets folder to your application and you can use it.http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

Sujit
  • 10,512
  • 9
  • 40
  • 45
  • Thanks Sugit I understand this portion of it , I'm wondering if its still easy to be populating it using information from Server in hte future ? Or would I hvae to overhaul my code if i want to access the server and populate my list from there ? – jamen Jun 03 '11 at 05:18
  • 1
    If you want to access data from server then you must need web service for this . There is no either way for this... – Sujit Jun 03 '11 at 05:23
0

You can create new Sqlite file using SQlite manager and then use these links to copy that database in your application.First put the database (SQlite file)in assets folder and then copy it using method shown in these answers:

Database not copying from assets

adding your own SQLite database to an android application

Community
  • 1
  • 1
Jaydeep Khamar
  • 5,975
  • 3
  • 32
  • 30
  • Hey Jaydeep thank you ! I was actually encountering the problem in "DATABASE NOT COPYING FROM ASSETS" and your solution solved it. I renamed the sql file to "drugs.sqlite" rather than leaving it as "drugs" and the whole file was copied over. Why did it happen ? – jamen Jun 03 '11 at 07:16
0

As per my opinion, If you implement test database and then if you implement web data fetching functionality then both will take your valuable time. So go either with web fetching or dummy database creation and then use it.

If you want to implement dummy sqlite database then for that you can use SQLite Browser, it is a plugin available inside the Mozilla firefox browser, no need to download it from anyware. Using this SQLite tool you can create the dummy database as you want. Once you are done with database creation, put it inside the assets folder and then use it inside the application. for the reference how to use your already created sqlite database inside the application, refer this link: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/.

If you want to implement web data fetching functionality, then you have to write a code to make webservice call. For this just google, as of this time many articles are available. Here is the best example: http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/.

One more example to Retrieve JSON from a REST web service

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • Hey Paresh, thank you yes that was what i wanted to do. Would it be advisable that I set up a Sqlite database using the first link, then implement web data fetching to append/replace data to the existing sqlite file in my device ? Is what I'm doing making sense at all ? Because i'm thinking more of like an engineer rather than a coder :S new to coding ... – jamen Jun 03 '11 at 07:26
  • See jamen, as per your query, you need to load the initial database and then do add/update/delete operation as per your requirement. – Paresh Mayani Jun 03 '11 at 07:40