I'm getting an error stating: "SQLiteCantOpenDatabaseException: unable to open database file (code 14)" on the line: if (cursor != null && cursor.moveToFirst()) {
and on
data = dbHelper.getTblQuoteNotify("tblQuoteNotify", nCounter);
I have <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
which seems to be the most common resolution to this issue from my research - can anyone else take a look at the code below and let me know what I may have done wrong in this instance?
Source:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
doTimerTask();
setContentView(R.layout.activity_main);
data_textview = (TextView) findViewById(R.id.data);
timer = (TextView)findViewById(R.id.timer);
dbHelper = new DBHelper(this);
try {
dbHelper.CopyDataBaseFromAsset();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dbHelper.openDataBase();
data = new Data();
}
public void doTimerTask(){
mTimerTask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
nCounter++;
// update TextView
timer.setText("Notify: " + nCounter);
data = dbHelper.getTblQuoteNotify("tblQuoteNotify", nCounter);
if (data != null) {
data_textview.setText(data.tblQuoteNotify);
}
Aucun commentaire:
Enregistrer un commentaire