MainActivity.java
public class MainActivity extends AppCompatActivity {
DbHelper dbHelper;
...
dbHelper = new DbHelper(this, 1, "garbage.db"); // I just only changed this 3rd argument so i think the problem is because of the db file itself not the code
try {
dbHelper.openDatabase();
} catch (Exception e) { // I got error here
e.printStackTrace();
}
try {
dbHelper.createDatabase();
} catch (Exception e) {
e.printStackTrace();
}
...
}
DbHelper.java
public class DbHelper extends CopyDatabase {
...
public DbHelper(Context context, int version, String databaseName) {
super(context, version, databaseName);
mcontext = context;
}
...
}
I just wanna open a sqlite db file in my assets folder and i succeeded to open one that i found on the internet which is a .db file.
But it didn't contain the exact data that i was looking for so i just tried to make one.
First i used DB browser tool to creat my sqlite database file. I executed queries using the tool and created a .db file.
And then i moved it to the assets folder and i tried to open it as just changing only the 3rd argument of DBhelper constructor which is referring the name of db file. But it didn't work. Here is the error code
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
I thought it might because of that i used the DB browser tool to create my db file so i made one more with using just sqlite3 in the shell script and it didn't work as well.
So for the last i tried it with sqlite jdbc library and created a .db file using eclipse .
And it didn't work.
So I'm stuck here.
What would be the reason for this problem?