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. Can an image be embedded in an email body?

Hi guys,

Hope you can help me with my question.

I am trying to embed an image in an email body.  I am trying to use
the ImageGetter to retrieve the bitmap, and send my Intent like this:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_SUBJECT,
getResources().getString(R.string.recommend_vid_title));
intent.putExtra(Intent.EXTRA_TEXT   , Html.fromHtml(emailBody, imgGet,
null));

When viewing the draft using the GMail app, all I see is [OBJ] instead
of the bitmap.

I tried setting the email contents to a TextView just to check if it
is correctly formatted and the image shows up fine.  Is this a problem
with the GMail app or am I doing something stupid?

I am testing using the Samsung Galaxy S.  Hope someone can help. :)
Thanks in advance!


Best regards,
Zarah.

--

2. INSTALL_FAILED_MISSING_SHARED_LIBRARY on Galaxy tab with SprintTwinCamDevice Library

Hi everybody,
I'm new in Android development,
And I have to develop a video tchat for The Galaxy Tab.
So, I have to display the front facing camera.
I develop with FlashBuilder 4, and I found on the internet that it was
possible with the SprintAndroidForwardFacingCamera library.
So I followed the tutoriel with adding my library to my IDE in
"Preferences/java/usesr libraries" and adding it to my project in the
"Java build path/Librairies".
After that I wrote <uses-library
android:name="com.sprint.hardware.twinCamDevice"></uses-library>
in the Manifest file between the <application> tag.
But when I launch my application on the device (samsung Galaxy Tab) or
on the virtual avd Galaxy tab, I had the following message
"Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY".
Is anybody had the same problem and found the solution.
Thanks for your help.

-- 

3. NFC Question

4. kernel support differences between Android versions?

5. Fwd: [WTS]iBank Transaction Downloader

6. Paging user Desire Z

7. Ada yang tau PM nya Master Lesjaw?