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. 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://
android-developers.blogspot.com/2008/08/some-information-on-apis-
removed-in.html)

I have two queries

Q1)   G1 was able to come up with BT profiles    1)headset    2hands
free
        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
AndUzer
--~--~---------~--~----~------------~-------~--~----~

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