1.使用intelij idea創建一個andorid項目
2.創建如下工具類:
MyDBHelper.java
package com.amos.android_database;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
/**
* Created by amosli on 14-6-10.
*/
public class MyDBHelper extends SQLiteOpenHelper{
/**
* 創建資料庫的構造方法
* @param context 應用程序上下文
* name 資料庫的名字
* factory 查詢資料庫的游標工廠一般情況下用sdk默認的
* version 資料庫的版本一般大於0
*/
public MyDBHelper(Context context) {
super(context, "test.db", null, 4);
}
private String tag = "MyDBHelper.class";
/**
* 在資料庫第一次創建時會執行
* @param db
*/
@Override
public void onCreate(SQLiteDatabase db) {
Log.d(tag,"onCreate.....");
//創建一個資料庫
db.execSQL("create table person (personid integer primary key autoincrement ,name varchar(30) )");
}
/**
* 更新數據的時候調用的方法
* @param db
* @param oldVersion
* @param newVersion
*/
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.d(tag,"onUpgrade*******");
//增加一列
db.execSQL("alter table person add phone varchar(13) null");
}
}
MyActivity.java
package com.amos.android_database;
import android.app.Activity;
import android.os.Bundle;
public class MyActivity extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyDBHelper myDBHelper = new MyDBHelper(this);
myDBHelper.getReadableDatabase();
myDBHelper.close();
}
}
3.打開生成的test.db
1).下載安裝SQLiteStudio(SQLite的可視化工具)
下載地址:http://www.sqlitestudio.pl/
安裝:
chmod 777 sqlitestudio-2.1.5.bin
./sqlitestudio-2.1.5.bin
執行上面的linux命令,第一句是賦許可權,第二句是打開工具
2)從avd中導出test.db
打開DDMS,從data/data/com.amos.andriod_database/databases下導出test.db
3).用sqlitestudio打開test.db
添加資料庫
選擇test.db
執行onCreate方法時創建的person表
執行onUpgrade方法更新語句的時候
B. sqlitestudio打開bak文件
摘要 您好!1、首先,在要轉移到的項目目錄下,新建db文件夾,然後將BAK 文件拷貝進去
C. mac版的 sqlite studio 怎麼打開資料庫
下載sqliteStudio,解壓,如圖,打開sqliteStudio.exe
即可使用
打開,如圖
新建資料庫,點擊database-add
database
輸入資料庫名,點擊OK
點擊數據名,在Table
右擊,然後create
a
table
6
設置資料庫的如圖所示,大家可以詳細的了解了。
D. 用SQLiteStudio 怎麼打開加密的資料庫
下載sqliteStudio,解壓,如圖,打開sqliteStudio.exe 即可使用 打開, 新建資料庫,點擊database-add database 輸入資料庫名,點擊OK 點擊數據名,在Table 右擊,然後create a table 設置資料庫的如圖所示,大家可以詳細的了解了。
E. 怎麼使用SQLiteStudio來管理Sqlite資料庫
下載sqliteStudio,解壓,如圖,打開sqliteStudio.exe
即可使用
打開,如圖
新建資料庫,點擊database-add
database
輸入資料庫名,點擊OK
點擊數據名,在Table
右擊,然後create
a
table
設置資料庫的如圖所示,大家可以詳細的了解了。
F. sqlitetudio打不開
打開SQLite Studio,點擊「添加資料庫」按鈕,:
圖解SQLite Studio的使用
數據類型選擇「System.Data.SQLite」,點擊綠色添加按鈕,將文件保存至D:Test.db,並在Password一欄內輸入密碼:2017(如不使用密碼,此處留空即可),然後點擊「OK」按鈕即可創建一個加密版本的SQLite DB文件,:
圖解SQLite Studio的使用
雙擊「Test」資料庫,將會顯示其下的子節點,選擇「Tables」,並在工具欄點擊「新建表」按鈕,:
圖解SQLite Studio的使用
在Table name文本框內輸入表名Info,並點擊「Add columns(Ins)」圖標以便添加列,:
圖解SQLite Studio的使用
添加第一個欄位,欄位名為ID,數據類型為Text,將主鍵前的復選框打鉤,並點擊「OK」按鈕,:
圖解SQLite Studio的使用
重復第4個步驟,點擊「Add columns(Ins)」圖標以便添加另外一個列,欄位名為Name,數據類型為Text,將非空前的復選框打鉤,並點擊「OK」按鈕,:
圖解SQLite Studio的使用
點擊「Commit structure changes」圖標以便保存該表及欄位,:
圖解SQLite Studio的使用
在彈出的對話框點擊「OK」按鈕,即可完成表單的創建工作,:
圖解SQLite Studio的使用
選擇「數據」選項卡,點擊「插入行(Ins)」圖標按鈕,如下所示:
圖解SQLite Studio的使用
在行數據編輯欄里輸入兩條數據,第一條數據ID為2017、Name為LSB,第二條數據ID為2011、Name為CNC,:
圖解SQLite Studio的使用
添加數據完畢之後,點擊「提交(Ctrl+Return)」圖標按鈕提交剛才輸入的兩條數據,:
圖解SQLite Studio的使用
12
關閉SQLite Studio資料庫管理軟體。
G. android studio怎麼知道sqlite創建
1、創建資料庫表,並添加欄位:
String sql = 「CREATE TABLE person(personid integer primary key autoincrement, name varchar(20))」; // varchar(20) 沒有意義,是為了符合標准語法。
2、往已存在資料庫表中添加欄位:
[java] view plain
String sql = 「ALTER TABLE person add age integer」;
代碼1: SQLiteHelper.java
[java] view plain
public class SQLiteHelper extends SQLiteOpenHelper{
public SQLiteHelper(Context context) {
super(context, ".db", null, 2); // 第2個參數 資料庫的名字,第3個參數用默認的CusorFactory,第3個參數資料庫版本號
}
@Override
public void onCreate(SQLiteDatabase db) {
String sql = "CREATE TABLE person(personid integer primary key autoincrement, name varchar(20))";
db.execSQL(sql);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
String sql = "ALTER TABLE person add age integer";
db.execSQL(sql);
}
}
代碼2:DBTest.java <不懂Android studio單元測試流程點這里>
[java] view plain
public class DBTest extends AndroidTestCase{
public void test(){
SQLiteHelper sqLiteOpenHelper = new SQLiteHelper(this.getContext());
sqLiteOpenHelper.getWritableDatabase(); // 創建或更新資料庫,可以點該方法看具體實現
}
}
直接下載demo
H. 怎麼把已有的資料庫sqlite
下載system.data.sqlite安裝包,在system.data.sqlite.org上下載對應.NET Framework x.x版本的安裝包。安裝system.data.sqlite,按照提示一步一步執行即可。
下載SQLiteStudio,直接運行exe文件。創建資料庫,以及操作數據表等等。
環境搭建好後就開始創建C#工程了,這里舉例創建了一個Winform工程。在工程里引入system.data.sqlite.dll。注意:引用窗口打開後選擇瀏覽,在安裝目錄下找到dll。默認安裝路徑是 C:\Program Files\System.Data.SQLite\2010\bin。如果不是使用VS2010,路徑會不同
除了引用system.data.sqlite以外,還需要把SQLite.Interop.dll復制到程序根目錄。
5
至此C#操作SQLite的開發環境就搭建好了。
I. 怎麼在sqlite expert中打開android studio創建的資料庫
啟動Sqlite Expert後,點擊左上角新增資料庫,然後在彈出的對話框中點擊瀏覽
2
指定資料庫存放的路徑,並且給資料庫命名,後綴名建議設置為.db
3
其他的保持默認設置,然後點 OK
4
左側顯示了剛創建的資料庫
5
點擊上方菜單的新增表按鈕,然後在 Table Name那裡輸入表名,然後點擊下方的Add來添加表欄位
6
在彈出的對話框中設置欄位名(Name),欄位類型(Type),欄位長度(Size),是否可空(not null),然後點擊OK
依次類似添加其他欄位,創建好欄位後點擊下方的Apply
點擊上方的Data,然後點擊 + 來手動添加一行數據
新增了一行
雙擊新增的那行數據來進行編輯
依次類似可以添加多條數據記錄
點擊上方的 DLL 可以看到表結構的 Sql 語句腳本
點擊 Design--Index--Add來添加主鍵索引,勾選Primary,然後選擇需要作為主鍵的欄位,點擊Add,再點擊OK
依次類似可以添加其他的特性欄位
然後點擊OK
最後會顯示設置Index的列,然後點擊下方的Apply來確認設置
J. sqlitestudio怎麼添加數據
下載sqliteStudio,解壓,如圖,打開sqliteStudio.exe
即可使用
打開,
新建資料庫,點擊database-add
database
輸入資料庫名,點擊OK
點擊數據名,在Table
右擊,然後create
a
table
設置資料庫的如圖所示,大家可以詳細的了解了。