从Android应用程序的资源使用SQLite数据库 [英] Use sqlite database from Android app resources

查看:109
本文介绍了从Android应用程序的资源使用SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始Android的编程最近这么多多包涵:)

I've started Android programming recently so bear with me :)

我开发拥有全部保存在database.sql文件内容的应用程序。
我实现了SQLiteOpenHelper的子类,并添加database.sql到我的项目资产。

I develop an app which has all of its content stored in database.sql file. I've implemented a subclass of SQLiteOpenHelper and added database.sql to my project assets.

public class DBHelper extends SQLiteOpenHelper
{
public DBHelper (Context ctx)
{
  super(ctx, "database.sql", null, 1);
}
}

这件事不能正常工作。我刚刚得到一个异常每次我尝试做未便与DB时间:(

This thing doesn't work. I just get an exception every time I try to do smth with DB :(

推荐答案

您需要覆盖的onCreate和的onUpdate还有,看看谷歌的例子<一个href=\"http://rhs.softwarerevolution.com/auto-docs/portals/google-android-mac/java/html-google-android-mac-java/Notepad$c$cLab/Notepadv1Solution/src/com/android/demo/notepad1/NotesDbAdapter.java/source/SOURCE-NotesDbAdapter.java.html\"相对=nofollow>这里

You need to override onCreate and onUpdate as well, have a look to google's example here

这篇关于从Android应用程序的资源使用SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆