sqlite存mp3
Step-1: 首先將.mp3檔案放入Project的/res/raw/裡,如下:
程式一開始執行,建立一個資料庫,含有BLOB欄位,如下之指令:
sql = "create table mySong("
+ "song_no text not null, "
+ "song_mp3 blob );";
try {
db.execSQL(sql);
} catch (SQLException e) {
Log.e("ERROR", e.toString());
return;
}
Step-2: 從Project的/res/raw/讀取*.mp3歌曲,然後分段儲存到SQLite的BLOB裡,如下之指令:
InputStream is = getResources().openRawResource(rid);
int bufSize = 63*1024;
byte[] buffer = new byte[bufSize];
try {
int size = is.read(buffer);
while(size >= 0){
ByteArrayOutputStream out = new ByteArrayOutputStream(size);
out.write(buffer, 0, size);
out.flush();
out.close();
cv.put("song_mp3", out.toByteArray());
db.insert("mySong", null, cv);
size = is
相关文档:
//搜集整理了一下网上的代码.找了半天居然找不到一条插入语句.好郁闷的
//感觉速度还可以.小文件.很多小应用程序在用这个数据库
//SQLite使用办法.直接COPYDLL文件System.Data.SQLite.DLL到应用程序DEBUG目录下。 然后在项目中添加引用,找到这个文件即可
//添加引用
using System;
using System.Collections.Generic;
......
QT读写Sqlite数据库
//.h
/****************************************************************************
**
** Date : 2010-05-08
** Author : furtherchan
** If you have any questions , please contact me
**
****************************************************************** ......
代码很乱,而且没有用到模板,把html代码跟Python代码混在一起了,而且也没有用到web.py本身提供的数据库操作模块,绝对粗超的代码!
学习了很多东西,首先当然是web.py,然后是sqlite,接下来是time模块——看来也唯有不断的实践,才真正能进步!
说实在的,偶学html到现在这么久,还是半桶水,悲剧了!
01&n ......
SQLite数据库连接方式
SQLite.NET
Type: .NET Framework Class Library
Usage: System.Data.SQLite.SQLiteConnection
Basic
Data Source=filename;Version=3;
Version 2 is not supported by this class library.
Using UTF16
Data Source=filename;Version=3;UseUTF16 ......