Android的 - 在SD卡上的SQLite数据库 [英] Android - SQLite database on SD card

查看:170
本文介绍了Android的 - 在SD卡上的SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法,如何创建和我的应用程序,而不是/data/data/com.myapp/databases目录使用的数据库从SD卡?我知道它是不安全的,但是否有任何特殊的限制,如在SD卡上的数据库不能更大然后2GB?

is there any way, how to create and use database from SD card in my app instead of /data/data/com.myapp/databases directory? I know is it unsecure, but are there any special restriction like "database on SD card cannot be bigger then 2GB"?

感谢

Hmyzak

推荐答案

他是一个提议的解决方案,我发现在计算器

he is a proposed solution which i found in stackoverflow

File dbfile = new File("/sdcard/android/com.myapp/databases/mydatabase.db" ); 
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
System.out.println("Its open? "  + db.isOpen());

这里是 <一个href="http://stackoverflow.com/questions/1055188/can-i-download-an-sqlite-db-on-sdcard-and-access-it-from-my-android-app/1055566#1055566">link.

here is the link.

更新

我不知道,你可以使用这个随着SQLiteOpenHelper,但你肯定可以查询数据库对象。

i am not sure you can use this along with SQLiteOpenHelper, but you sure can query the database object.

db.getVersion();
db.execSQL(sql);
db.beginTransaction();
db.endTransaction();
db.setTransactionSuccessful();
db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);

你可以做所有你期待着与数据库中的东西。 SQLiteOpenHelper只有一个包装类,它可以帮助你,我们总能在我们自己做多余。

you can do all the things which you expect with a database. SQLiteOpenHelper in only a wrapper class which helps you the extra which we always can do on our own.

修改 为您的文件大小限制,我发现这个链接。 <一href="http://stackoverflow.com/questions/5217744/is-there-a-file-size-limit-on-android-honeycomb/5217950#5217950">Is有在Android蜂窝文件大小限制?

EDIT as for your file size limit i found this link. Is there a file size limit on Android Honeycomb?

这篇关于Android的 - 在SD卡上的SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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