Advise on which is the better way of creating the database in android
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 ?
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
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/
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
精彩评论