Have a look at this article.It should be enough for you.
http://androidexample.com/SQLite_Database_Manipulation_Class_-_Android_Example/index.php?view=article_discription&aid=51
EDIT
Handling SQLite is very easy and methodological procedure.
PROCEDURE 1(This is internal Storage)
Check whethere you have already the db in your external path or not.To do that use this below code.Please note this set of code should be written
in DBhelper class onCreate method.
if (!new File("/data/data/" + this.getPackageName()
+ "/database.sqlite").exists()) {
try {
FileOutputStream out = new FileOutputStream("data/data/"
+ this.getPackageName() + "/database.sqlite");
InputStream in = getAssets().open("databases/dic.db");
byte[] buffer = new byte[1024];
int readBytes = 0;
while ((readBytes = in.read(buffer)) != -1)
out.write(buffer, 0, readBytes);
in.close();
out.close();
} catch (IOException e) {
}
}else{
/database already exists.Do nothing
}
You should place this code, in your MainActivity's onCreate function. You can easily use your own database in whole of your project. To access your database, you can use the code as follow :
SQLiteDatabase sqliteDB = SQLiteDatabase.openOrCreateDatabase(
"/data/data/" + this.getPackageName() + "/database.sqlite",
null);
Cursor cursor = sqliteDB.rawQuery("SELECT * FROM table", null); // example of query
PROCEDURE 2(This is for External Storage)
Create a COnstructor in DBHelper Class
public DatabaseHelper(final Context context) {
super(context, Environment.getExternalStorageDirectory()
+ File.separator + FILE_DIR
+ File.separator + DATABASE_NAME, null, DATABASE_VERSION);
}
When you will be making the object of this DBHelper class the new db will be created in the external Path.And in OnCreate you check
whether that particular path is exists or not like this:
if (!new File(Environment.getExternalStorageDirectory()
+ File.separator + FILE_DIR
+ File.separator + DATABASE_NAME).exists()) {
SQLiteDatabase.openOrCreateDatabase(Environment.getExternalStorageDirectory()
+ File.separator + FILE_DIR
+ File.separator + DATABASE_NAME,null);
}else{
/database already exists.Do nothing
}