EugenSunic
EugenSunic

Reputation: 13693

Imported Sqlite Database not working in Android

I've been struggling with database import to my android project for a while, I'm new to android. I know that android supports sqlite so my first question is do I have to remove the .sqlite extension and replace it with .db since in the examples that I found on the net I only saw the .db extension files?. After I do that I place my existing database file to my assets folder and use a class to manage(create,copy) my database.

This is the tutorial which I am folowing:

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

In the tutorial it says that I must rename all of my id columns to _id , is that mandatory?

Upvotes: 1

Views: 502

Answers (1)

Phantômaxx
Phantômaxx

Reputation: 38098

The extension can be anything (better if .db).
The _id field is not mandatory.
I have all (really) of my DBs without an _id field.

I call the id fields whatever I want.
If then I need a special method that requires an _id field, then I fake it using the rowID AS _id trick.
rowID is a special "hidden" field that behaves exactly as if it was the _id field.

Upvotes: 2

Related Questions