简体   繁体   English

创建用于创建并连接到Android Sqlite3数据库的Java jar文件

[英]Create java jar file that creates and connects to Android Sqlite3 database

I am creating a java jar file that will be used to connect to different databases so this library can be used in many apps and support different databases. 我正在创建一个Java jar文件,该文件将用于连接到不同的数据库,因此该库可以在许多应用程序中使用并支持不同的数据库。 ie Sqlite3, MySQL, Oracle, etc. 即Sqlite3,MySQL,Oracle等。

Currently I want to support Android first and want my jar file to connect to Android's builtin Sqlite3 database. 目前,我想首先支持Android,并希望我的jar文件连接到Android的内置Sqlite3数据库。

The customer will use are jar file and call the functions in it to create, update, and query the database. 客户将使用jar文件,并调用其中的函数来创建,更新和查询数据库。 So they won't have to use any or Androids API. 因此,他们不必使用任何API或Androids API。

However, I am confused about a few things: 但是,我对一些事情感到困惑:

1) Can a java jar file create and connect to Android Sqlite3 database without importing the android.database.sqlite.* API. Just using Java's standard API?
2) As all apps are created and ran in their own sandbox on Android, will the database be created and saved to the apps sandbox for security reasons?

Many thanks for any suggestions, 非常感谢您的任何建议,

Unfortunately, if you want to create and connect to the built-in android sqlite database you must import android.database.sqlite.* 不幸的是,如果要创建并连接到内置的android sqlite数据库,则必须导入android.database.sqlite.*

About the other section of the question, i'm not sure if it's depends on the first one or not but if you use the android api to create it, sure it will be in the application private folder 关于问题的另一部分,我不确定它是否取决于第一个,但是如果您使用android api来创建它,请确保它将位于应用程序专用文件夹中

Can a java jar file create and connect to Android Sqlite3 database without importing the android.database.sqlite.* API. Java jar文件可以在不导入android.database.sqlite。* API的情况下创建并连接到Android Sqlite3数据库。 Just using Java's standard API? 仅使用Java的标准API?

sqlite databases are just files. sqlite数据库只是文件。 You can read and write files with regular Java APIs. 您可以使用常规Java API读写文件。

Though for database use it's better to use the sqlite3 C library for reading and writing the files. 尽管对于数据库使用,最好使用sqlite3 C库读取和写入文件。 Android provides one Java wrapper for it; Android为此提供了一个Java包装器。 there are a number of other wrappers as well, including JDBC ones. 还有许多其他包装,包括JDBC包装。

As all apps are created and ran in their own sandbox on Android, will the database be created and saved to the apps sandbox for security reasons? 在Android上创建并运行所有应用程序后,出于安全原因,是否将数据库创建并保存到应用程序沙箱中?

By default the Android database wrapper puts database files in the app's private data directory. 默认情况下,Android数据库包装器将数据库文件放在应用程序的私有数据目录中。 It's not accessible to other apps without shared user id or root. 没有共享用户ID或root的其他应用程序将无法访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM