创建的SQLite数据库中的Andr​​oid库 [英] Create SQLite DB in Android library

查看:129
本文介绍了创建的SQLite数据库中的Andr​​oid库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了很多的OnCreate和的OnOpen方法和SQLite数据库管理的Andr​​oid之间的关系。

I've seen a lot of ties between the onCreate and onOpen methods and SQLite database management in Android.

我是一名iOS开发者,我想翻译(这么说)我的可可库,以便它可以在Android上使用。我需要在运行时创建一个SQLite数据库。我没有一个活动 - 因为这是一个库,我创建。看来我不能创建一个数据库没有一个活动,这是正确的?

I am an iOS developer and I'm trying to "translate" (so to speak) my cocoa library so it could be used on Android. I need to create an SQLite database at runtime. I don't have an activity - since this is a library I'm creating. It seems I can't create a DB without an activity, is this correct ?

推荐答案

要创建的SQLite数据库,你不要基本上需要在library.it活动需要一个背景!,  您可以在库/类中的方法,基本上采取的输入/参数上下文,并创建数据库。

To create sqlite db, you don't basically need an activity in the library.it needs a context!!, You can have a method in library/class which basically take a context in input/parameter and create database.

此背景下,可以从应用程序的活动或服务,或接收器通过。

This context can be passed from application activity or service or receiver.

这篇关于创建的SQLite数据库中的Andr​​oid库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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