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
相关文档:
AutoIt3开发的操作SQlite数据库的源码下载
部分源码
_SQLite_Startup () ;加载 SQLite.dll
If Not FileExists($SQLite_Data_Path) Then
SQLCreate()
EndIf
$GUI_Form = GUICreate($Title, 300, 435, -1, -1)
GUISetBkColor(0xECE9D8) ; will change background color
$GUI_ListBox = GUIC ......
文章分类:数据库
SQLite在VC下的使用(转)http://www.sqlite.com.cn/MySqlite/4/523.Html
一、SQLite简介
SQLite
是用C语言编写的开源数据库,主要用于嵌入式,你也可以把它集成在自己的桌面程序中,也有人将其替代Access,用作后台数据库。
SQLite 支持多数SQL92 ......
package com.jiao.sqlite;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widg ......
1 TOP
这是一个大家经常问到的问题,例如在SQLSERVER中可以使用如下语句来取得记录集中的前十条记录:
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
但是这条SQL语句在SQLite中是无法执行的,应该改为:
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
其中limit 0,10表示从第0 ......