0

I want to read data from an external .db file in my android app. So I have a .db file and added it to my project folder.

Now I want to access to this file by JDBC, so I added a JDBC.jar file and connected to my DB with

    Class.forName("org.sqlite.JDBC");
    Connection conn = DriverManager.getConnection("jdbc:sqlite:myDatabase.db");

and it works fine in a normal java project.

But when I want to do it in an activity in my android project, I always get a ClassNotFoundException. I checked the class's existence in my android project. It's: 'myProject/Referenced Liberaries/sqlitejdbc-v056.jar/org.sqlite/JDBC.class', so the right path I think.

What's the reason for that exception?

Froxx
  • 957
  • 4
  • 14
  • 27
  • Is there a particular reason you are not using normal Android classes for accessing your SQLite database, such as `SQLiteDatabase`? – CommonsWare Feb 13 '14 at 20:28
  • check the answer of this question: http://stackoverflow.com/questions/7221620/android-jdbc-not-working-classnotfoundexception-on-driver – donfuxx Feb 13 '14 at 20:29
  • @CommonsWare: Well, I didn't really work with SQLiteDatabase before, and the couple of times I tried, I didn't get it very well. So i hoped that JDBC can do his job here. Is it that much more involved? [AT]donfuxx: With a webservice? I just have a local .db file and want to read data from it. Why should I do that with a web service? – Froxx Feb 13 '14 at 20:46
  • "Is it that much more involved?" -- I would guess that ~0.1% of Android developers use JDBC at all on Android and 0.05% use it for SQLite. There is more than enough written about the use of classes like `SQLiteDatabase` and `SQLiteOpenHelper` that developers who want to learn them should not have much difficulty. – CommonsWare Feb 13 '14 at 20:54

0 Answers0