目前是2 m大小。
站在用戶的角度思考問題,與客戶深入溝通,找到臨潼網(wǎng)站設計與臨潼網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都網(wǎng)站設計、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名申請、虛擬主機、企業(yè)郵箱。業(yè)務覆蓋臨潼地區(qū)。
希望我的回答可以幫到你,有什么不懂可以追問。
SQLiteOpenHelper(frameworks/base/core/java/android/database/sqlite /SQLiteOpenHelper.java)這個類中,創(chuàng)建數(shù)據(jù)庫文件的路徑是使用傳入的contex的getDatabasePath獲取的,這個 是不允許修改的(至少我沒有找到)。
那我就仿照這個SQLiteOpenHelper寫了一個abstract class SDSQLiteOpenHelper,其使用和SQLiteOpenHelper一樣,然后只要加上相應的permission,這樣就可以實現(xiàn)把數(shù)據(jù)庫存儲到sdcard上了。
嘗試著研究了下Html5訪問本地數(shù)據(jù)庫,感覺還不錯,用的是chome瀏覽器,sqlite數(shù)據(jù)庫。
xp系統(tǒng)默認的數(shù)據(jù)庫存放路徑C:\Documents and Settings\Administrator\Local Settings\Application Data\Google\Chrome\User Data\Default\databases\
具體的數(shù)據(jù)庫文件要動手找,用SQLitespy可以打開數(shù)據(jù)庫
示例代碼:
html manifest="mymanifest.manifest"
head
meta http-equiv="Content-Type" content="text/html; content="no-cache" charset=utf-8" /
script type="text/javascript" src="jquery-1.7.2.min.js"/script
script
$(document).ready(function(){
databaseTest();
});
function databaseTest(){
//open database
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS testHtml (id unique, contentText)');
tx.executeSql('INSERT INTO testHtml (contentText) VALUES ("insert data test1!")');
// tx.executeSql('delete from testHtml');
});
db.transaction(function(tx){
tx.executeSql('SELECT * FROM testHtml',[],function(tx,result){
var len=result.rows.length;
var msg = "pFound rows: " + len + "/p";
$("#testinfo").append(msg);
for(var i = 0; i len ; i++){
var str=result.rows.item(i);
$("#testvalue").append(str.contentText);
}
},null);
});
}
/script
/head
body
divhere is test info:/div
div id="testinfo"/div
divhere is test value:/div
div id="testvalue"/div
/body
如果用的Chrome瀏覽器
那么SQLite數(shù)據(jù)庫就安裝到了$CHROME_HOME\User Data\Default\databases中
這個目錄中databases.db是當前用戶的所有創(chuàng)建的數(shù)據(jù)庫的配置,而file__0目錄則是數(shù)據(jù)庫表文件
其他瀏覽器也應該差不多
。所謂html5是作為一種標準。而最終實現(xiàn)是需要瀏覽器內(nèi)核支持。無論是顯示還是數(shù)據(jù)庫鏈接 和 瀏覽器內(nèi)核有關(guān)。然后。html5 是支持SQLite的連接的。需要使用js的數(shù)據(jù)庫操作的一套api。chrome應該是比較好支持的
指定sqlite的創(chuàng)建位置
=================
要在Android系統(tǒng)中操作SQLite數(shù)據(jù)庫,是通過Android的核心類SQLiteDatabase類來實現(xiàn)的,通常情況下為了數(shù)據(jù)庫升級的需要以及使用方便,我們會選擇繼承SQLiteOpenHelper抽像類,但是SQLiteOpenHelper會將數(shù)據(jù)庫文件創(chuàng)建在一個固定的目錄(內(nèi)存的/data/data/package name/databases目錄中),如果你想使用已經(jīng)存在的數(shù)據(jù)庫文件也就是說數(shù)據(jù)庫會和程序一起發(fā)布,就得通過使用SQLiteDabase的靜態(tài)方法OpenOrCreateDatabase()方法來得到SQLiteDabase對象,下面是一個具體操作類:
package net.my.dao;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import net.my.jokebook.R;
import android.app.Activity;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
public class DBHelper {
//得到SD卡路徑
private final String DATABASE_PATH = android.os.Environment
.getExternalStorageDirectory().getAbsolutePath()
+ "/joke";
private final Activity activity;
//數(shù)據(jù)庫名
private final String DATABASE_FILENAME;
public DBHelper(Context context) {
// TODO Auto-generated constructor stub
//這里直接給數(shù)據(jù)庫名
DATABASE_FILENAME = "jokebook.db3";
activity = (Activity)context;
}
//得到操作數(shù)據(jù)庫的對象
public SQLiteDatabase openDatabase()
{
try
{
boolean b = false;
//得到數(shù)據(jù)庫的完整路徑名
String databaseFilename = DATABASE_PATH + "/" + DATABASE_FILENAME;
//將數(shù)據(jù)庫文件從資源文件放到合適地方(資源文件也就是數(shù)據(jù)庫文件放在項目的res下的raw目錄中)
//將數(shù)據(jù)庫文件復制到SD卡中 File dir = new File(DATABASE_PATH);
if (!dir.exists())
b = dir.mkdir();
//判斷是否存在該文件
if (!(new File(databaseFilename)).exists())
{
//不存在得到數(shù)據(jù)庫輸入流對象
InputStream is = activity.getResources().openRawResource(
R.raw.jokebook);
//創(chuàng)建輸出流
FileOutputStream fos = new FileOutputStream(databaseFilename);
//將數(shù)據(jù)輸出
byte[] buffer = new byte[8192];
int count = 0;
while ((count = is.read(buffer)) 0)
{
fos.write(buffer, 0, count);
}
//關(guān)閉資源
fos.close();
is.close();
}
//得到SQLDatabase對象
SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(
databaseFilename, null);
return database;
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
return null;
}
}
寫完這個類之后,就能得到SQLiteDatabase對象,就能對數(shù)據(jù)庫操作了
當前題目:sqlitehtml5的簡單介紹
地址分享:http://vcdvsql.cn/article6/dsdijig.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供用戶體驗、網(wǎng)站制作、標簽優(yōu)化、Google、App開發(fā)、微信小程序
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)