导入现有数据库

时间:2014-03-05 22:02:38

标签: android sqlite

我使用了这个http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ databasehelper类

然后我做了一个适配器类

public class DbAdapter {
    private static final String LOG_TAG = DbAdapter.class.getSimpleName();

      private Context context;
      private SQLiteDatabase database;
      private DataBaseHelper dbHelper;

      private static final String DATABASE_TABLE= "MN1";

      public static final String KEY_CONTACTID = "_id";
      public static final String KEY_NUM = "Numero";
      public static final String KEY_NOME = "Nome";
      public static final String KEY_TIPO = "Tipo";
      public static final String KEY_LUOGO = "Luogo";

      public DbAdapter(Context context) {
            this.context = context;
          }
      public DbAdapter open() throws SQLException {
            dbHelper = new DataBaseHelper(context);
            database = dbHelper.getWritableDatabase();
            return this;
          }

          public void close() {
            dbHelper.close();
          }

          private ContentValues createContentValues(String Numero, String Nome, String Tipo, String Luogo) {
            ContentValues values = new ContentValues();

           return values;
          }

          public Cursor fetchAllContacts() {
                return database.query(DATABASE_TABLE, new String[] { KEY_CONTACTID, KEY_NUM, KEY_NOME, KEY_TIPO, KEY_LUOGO}, null, null, null, null, null);

我试图运行它错误它给出了错误“没有这样的表:MN1:,同时编译SELECT _id ecc”

我去了数据库文件夹,实际上有一个名为MN1的数据库,这是元数据表。

怎么了?

修改

public class DataBaseHelper extends SQLiteOpenHelper{

//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/com.example.provadatabase/databases/";


private static String DB_NAME = "MN1";

private SQLiteDatabase myDataBase;

private final Context myContext;

0 个答案:

没有答案