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:
   http://code.google.com/android/intro/tutorial.html 

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


Anm



--~--~---------~--~----~------------~-------~--~----~


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);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + POINTS_TABLE_NAME + " ("
+ Points._ID + " INTEGER PRIMARY KEY,"
+ Points.NOMBRE + " TEXT,"
+ Points.DESCRIPCION + " 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"
+ ");");
}

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

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

switch (sUriMatcher.match(uri)) {
case POINTS:
qb.setTables(POINTS_TABLE_NAME);
qb.setProjectionMap(sNotesProjectionMap);
break;

case POINT_ID:
qb.setTables(POINTS_TABLE_NAME);
qb.setProjectionMap(sNotesProjectionMap);
qb.appendWhere(Points._ID + "=" +
uri.getPathSegments().get(1));
break;

default:
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. notepad tutorial problem with Input configuration changed

When switching from portrait to landscape view when you are creating a
new note, i.e. revealing the keyboard, causes the application to
unexpectedly stop. Has anyone else had this problem? have you fixed
it?



--~--~---------~--~----~------------~-------~--~----~

2. Main App & SurfaceHolder?

Hey guys, total Android noob here. :)

For my first app, I'm having a go at developing a simple video camera
app.
(There isn't one yet~!)

So I've been reading through the docs, and I've come up with a tiny
bit of code.

...Sorry if there's code tags. (I'm a mod over at another forum, I
know the rules!) ;)

Anyway, I digress.

package com.android.hello;

import android.app.Activity;
import android.os.Bundle;
import android.hardware.Camera;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Camera cam = Camera.open();
        cam.startPreview();
    }
}

I'm stuck on assigning something with cam.setPreviewDisplay();

I've looked in the docs, and come across this method. I know it takes
a SurfaceHolder as a parameter.

But I can't instantiate a SurfaceHolder object, so I'm assuming the
main app has one?

Thanks in advance,
Danny

--~--~---------~--~----~------------~-------~--~----~

3. how to get menu handler

4. Access point signal level updating

5. Is it possible to buy G1 developer device from Italy?

6. Compass Cals

7. Using WebView with AlertDialog