Every time I am using db and I can not remove it.
I use this code for SQL when I have a query:
public class GameSQLHelper {static last string} country = new string [] {"Afghanistan "," Albania "," Algeria "," American Samoa "," Andorra "}; Personal Static Last String DB_PATH = "/ countryCityGame / Database /"; Private Static Last String DATABASE_NAME = "events.db"; Personal Static FINAL END DATABASE_VERSION = 1; Private Final Reference MCTX; // table name public static final string table = "myDataBase"; // column public static final string letter = "letter"; Public static final string type = "type"; Public static final string value = "value"; // my database SQLiteDatabase myDataBase; Private Static Class DatabaseHalper SQLiteOpenHelper Extended {Private Stable Last String TAG = Zero; DatabaseHelper (reference reference) {super (references, database ANNN, blank, databasebaseSSns); } @ Override Public Wide on Crate (SQLiteDatabase db) {String SQL = "Creating Table" + Tab + "(" + BassColmos.IID + "Integer Primary Key Autocarment," + + + "Text Not False," + TYPE + "Text not null," + VALUE + "text is not empty);"; Log D. ("EventData", "On Crate:" + sql); Db.execSQL (SQL); InsertValuesToDB (database); } Enter the private Zero SQLiteDatabase db {if (db == empty) {} else {db.execSQL ("INSERT INTO" + + TABLE + "(" + LETTER + "," + TYPE + "," + VALUE ") + ")" + "Value ('A', 'country', 'angola');); Material values initial value = new material value (); For (int i = 0; i & lt; COUNTRIES.length; i ++) {character TMP = (character) countries [i] .charAt (0); initial value. Input (VALUE, country [i]); InitialValues.put (TYPE, "Country"); InitialValues.put (letter, tmp.toString (tmp)); Db.insert (table, blank, initial value); }}} @parride public appointment on upgrade (SQLiteDatabase db, int oldwarson, it's news) {log. Upgrading database from W ("Tag," version "+ old version +" to "+ new version +"), which will destroy all old data "); DB.XACSQL (" Recond Table, if Note " ); OnCreate (Database);}} / ** * Constructor - Opens the database * Opened / Created * * @ Refers to reference in the context of the ultimate CTX in which to work * / Public GameSQLHelper (Reference CTX) {This.mctx = ctx;} Upgrade to Public Zero (SQLiteDatabase Db, int oldwarson, int neversen) {if (old version> gt; = new version) returns; string sql = null; if (old version == 1) sql = "change table" + tab + "add note text;" ; (Sql! = Null) db.execSQL (sql);} Public Zero Access Database (); (Old version == 2) sql = ""; Log D. ("EventData", "Ongrade:" + SKL); SQLException throws {// database string open myPath = DB_PATH + DATABASE_NAME; MyDataBase = SQLiteDatabase.openDatabase (myPath, blank, SQLiteDatabase.OPEN_READWRITE);} in public boolean Jud Handetabes (string Searchers) {cursor C = NULL; Try {OpenDataBase (); C = myDataBase.query (true, table, new string [] {TYPE}, VALUE + "=" + serchStr, blank, empty, blank, empty, empty); } Hold (exception e) {log d. ("SqlExacption", e.getMessage ()); } If returned (C == empty) wrong; Back true; }}
Every time I call this class (I have been installed it: mDbHelper = new GameSQLHelper (this);
where it is an activity )
I always consider my mDbHelper to be nonsensical how can I change it? This is my first time working with SSL, mysql is out of the forum, so I'm having problems understanding this kind of concept and the Android Notepad example did not help me.
Do not open the database via SQLiteDatabase # openDatabase
. Instead, make an example of your DatabaseHelper
and call it on getWritableDatabase
.
Comments
Post a Comment