I want to Connect my app with a database on the Android Phone, so I've written a class called DBHelper.
But I get An Error, which says "MODE_PRIVATE" cannot be resolved to a variable. So i made "Context.MODE_PRIVATE". Now, the Variable can be resolved, but I get a new Error:
"The method openOrCreateDatabase(String, int, null) is undefinded for the Type DBHelper".
It doesn't help if I use DBHelper.this.openOrCreateDatabase to open it.
Can anybody help me?
This is my Code:
public class DBHelper {
SQLiteDatabase db;
public void insert(String news, Context con){
db = openOrCreateDatabase("PlanB", con.MODE_PRIVATE, null);
db.execSQL("DROP TABLE IF EXISTS News");
db.execSQL("CREATE TABLE IF NOT EXISTS INBOX(id INTEGER,title VARCHAR,text VARCHAR,date VARCHAR);");
String[] divided = news.split("/newentry/");
int length = divided.length;
int pos = 0;
while(pos <= length){
String[] entry = divided[pos].split("/;/");
db.execSQL("INSERT INTO INBOX VALUES('"+entry[0]+"','"+entry[1]+"','"+entry[2]+"','"+entry[3]+"');");
pos++;
}
db.close();
}
}
con.openOrCreateDatabase("PlanB", con.MODE_PRIVATE, null);?Context.MODE_PRIVATE