I'm try to create a new database
and table
in my constructor class
, but I find in this line error:
db.execSQL("CREATE TABLE IF NOT EXIST tblApp ( _ID INTEGER PRIMARY kEY AUTOINCREMENT UNION, Title TEXT )",null);
and crashed my app.
This is my class:
package ir.rezvania.modirbash;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Toast;
public class db {
Context ctx;
Cursor crs;
private SQLiteDatabase db;
public db(Context ctx){
this.ctx=ctx;
db = ctx.openOrCreateDatabase("`dbApp`", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXIST `tblApp` ( _ID Integer Primary key autoincrement union, Title Text )",null);
}
public void Insert(String FILDS,String VALUES){
db.execSQL("INSERT INTO `tblApp` ("+FILDS+")VALUES("+VALUES+");");
}
public void Update(String ID,String COLUMN,String VALUE){
db.execSQL("UPDATE `tblAPP` SET"+COLUMN+"="+VALUE+"WHERE _ID="+ID+";");
}
public void Delete(String ID){
db.execSQL("DELETE FROM `tblApp` WHERE _ID="+ID+";");
}
public Cursor Show(){
crs=db.rawQuery("SELECT * FROM `tblApp`",null);
return crs;
}
public void finalize(){
db.close();
}
}