开发者

Setting up sqlite database

Sorry I am a noob, I am trying to learn about sqlite databases using linux, I cannot find any tutorial that covers what I need from setup to creating to using. At the moment tutorials I fin开发者_如何学God say open a shell using adb shell command but when I open a terminal this does not work even if I navigate to the android tools folder, I can get the sqlite command working but the tutorials dont explain how I use it. For instance, how do I store urls and map coordinates and how to I reference them.

I have tried to use the firefox plugin but I havent got a clue what it all means and every tutorial says sqlite database is easy but it seems so complicated.......HELP!!!!

P.S would it be possible to create the data within the application code, I have seen some apps that do this

Does anyone have a set up guide and tutorial that can help?


Take a look here: http://developer.android.com/guide/topics/data/data-storage.html#db

You should use a custom class extending SQLiteOpenHelper: http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html

It gives you methods like onCreate, onOpen and onUpgrade which are very useful.


To set up your database :

The recommended method to create a new SQLite database is to create a subclass of SQLiteOpenHelper and override the onCreate() method, in which you can execute a SQLite command to create tables in the database.

To use it :

You can execute SQLite queries using the SQLiteDatabase query() methods, which accept various query parameters, such as the table to query, the projection, selection, columns, grouping, and others. For complex queries, such as those that require column aliases, you should use SQLiteQueryBuilder, which provides several convienent methods for building queries.


Resources :

  • developer.android.com - Data Storage


Are you using Java. You can have a look http://www.zentus.com/sqlitejdbc/


Android has a class named SqliteOpenHelper using which you can create and communicate(do read / write operations) on sqlite using java. You can find many samples once you start searching in net. Here is one such sample.

http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

If you want to open your database you can use Sqlite Manager which is available with Firefox as a Addon. It has a easy interface so that you can load your database directly and check .


If you are planning to create a new SQLite database then over ride and implement the onCreate() Method.

But if you are using a SQLite database that is created by another external source and you are going to pull it down, then leave the onCreate() method empty.


You might look at SQLite Manager, which is a free GUI and available in a Linux variety. I highly recommend it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜