I already saw an example of using SQlite in android...but in that particular example, records are inserted each time the app is ran..But i wanted to insert it only once and permanently! any possibilities???
SQLite is another data storage available in Android where we can store data in the user's device and can use it any time when required.
Which of the following is used to insert a data into the database in Android? Android SQLite is the most preferred method of storing data in any android applications. Android SQLite is a relational database, therefore, It supports all types of relational database features.
//DB HANDLER CLASS
public void saveRecords(String info, int otherinfo, int greatinfo){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(STRING_COLUMNA, info); // inserting a string
values.put(STRING_COLUMNB, otherinfo); // inserting an int
values.put(STRING_COLUMNC, greatinfo); // inserting an int
// Inserting Row
db.insert(TABLE_NAME, null, values);
db.close(); // Closing database connection
}
Good luck!
Insert values in onCreate
method of your SQLiteOpenHelper. It called only when your DB had been created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With