Lambros
Lambros

Reputation: 151

android studio sqlite method error

I have this code:

import android.database.sqlite.SQLiteDatabase;

public class ConnectDB { 
SQLiteDatabase db = openDatabase("/assets/products.sqlite",MODE_PRIVATE,null);
    }

I am getting an error that openDatabase method not found. How can I connect to this sqlite file and get the contents?

Thank you!

Upvotes: 0

Views: 258

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006604

Assuming that your database is packaged as an asset in assets/ in your project, that is not a file on the filesystem of the device. Use SQLiteAssetHelper to unpack the packaged database and put it on the filesystem for your use.

Upvotes: 1

Related Questions