Create Data Base

by andrex » Wed, 22 Oct 2008 03:53:09 GMT

Sponsored Links
 Hi all, i was loking for an example of how to create a date base in
sqlitedabase, but I was'n lucky. May someone help me whit that, maybe
an example or a document. Thanks

Create Data Base

by Anm » Wed, 22 Oct 2008 04:02:22 GMT

 Walk through the Notepad example: 

Then study the file for the specifics of how it
creates and interfaces with the database.



Sponsored Links

Create Data Base

by andrex » Fri, 24 Oct 2008 00:12:25 GMT

 hanks Anm, but I'm looking for something diferent, i want to create a
class like this(I got it from android example):

public class base extends ContentProvider {
private static final String TAG = "Base";

private static final String DATABASE_NAME = "base.db";
private static final int DATABASE_VERSION = 2;
private static final String POINTS_TABLE_NAME = "points";
// private static final String CITY_TABLE_NAME = "city";
// private static final String CATEGORY_TABLE_NAME = "category";

private static HashMap<String, String> sNotesProjectionMap;

private static final int POINTS = 1;
private static final int POINT_ID = 2;

private static final UriMatcher sUriMatcher;

private static class DatabaseHelper extends SQLiteOpenHelper {

DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);

public void onCreate(SQLiteDatabase db) {
+ Points.NOMBRE + " TEXT,"
+ Points.DIRECCION + " TEXT,"
+ Points.ALTITUD + " TEXT,"
+ Points.ID_CAT + " TEXT,"
+ Points.ID_CIUDAD + " TEXT,"
+ Points.LATITUD + " TEXT,"
+ Points.LONGUITUD + " TEXT,"
+ Points.URL + " TEXT,"
+ Points.TELEFONO + " TEXT"
+ ");");

public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion
+ " to "
+ newVersion + ", which will destroy all old
db.execSQL("DROP TABLE IF EXISTS notes");
private DatabaseHelper mOpenHelper;

public boolean onCreate() {
mOpenHelper = new DatabaseHelper(getContext());
return true;
public Cursor query(Uri uri, String[] projection, String
selection, String[] selectionArgs,
String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

switch (sUriMatcher.match(uri)) {
case POINTS:

case POINT_ID:
qb.appendWhere(Points._ID + "=" +

throw new IllegalArgumentException("Unknown URI " + uri);

// If no sort order is specified use the default
String orderBy;
if (TextUtils.isEmpty(sortOrder)) {
orderBy = tablas.Points.DEFAULT_SORT_ORDER;
} else {
orderBy = sortOrder;

// Get the database and run the query
SQLiteDatabase d

Other Threads

1. Loading a Spinner

Does anyone have a good example of loading a  spinner from a specific column in 
a sqlite db table.  I think I'm missing something.


2. G1 bluetooth support doubts

Hi ,

I am new to Android and my scope of work is Bluetooth applications
using Android Application Framework. I found that Android Application
Framework does not support any BT APIs .

After a lot of digging through the various Android communities , I
could conclude that Google removed the Bluetooth API support (http://

I have two queries

Q1)   G1 was able to come up with BT profiles    1)headset    2hands
        I am not able to understand how G1 has BT support although
there is no BT Application Framework supported in the SDK  ,Was it
using the org.bluez( which is now removed) ???

Q2)     Post SDK1 era, is it possible to implement even basic
Bluetooth functionality(pairing,discovery etc) in any way without any
Android Application Framework support

Thanks in advance

3. Is there a function to decode XML/HTML encoding?

4. How to generate tones for keys

5. Site is unavailable

6. android:allowClearUserData and android:manageSpaceActivity

7. blank screen