Ⅰ 如何往android中添加資料庫
一、新建外部SQLite資料庫
(1)下載並安裝 SQLite可視化管理工具(SQLite Expert Pro) v3.4.17 破解版
http://www.cr173.com/soft/36343.html
(2)將你手頭上的數據放到EXCEL表格中,保存為CSV格式的數據
(3)在此工具中按照你現有的數據格式新建資料庫和表,如資料庫為:contact.db,表為employee
(4)通過此工具菜單欄中Import/Export下的Import text file(CSV,TSC)功能,將你現有的CSV數據導入到你新建的數據表中(主要目的是省的一個一個的錄入了)
二、在eclipse中新建一個android app工程,並在新建的工程文件夾點右鍵new->folder,在res文件夾下新建raw文件夾(如果有就不用新建了)
三、用滑鼠將新建的SQLite資料庫文件contact.db拖動到新建工程的res下的raw文件下,出現提示,選擇
四、程序代碼
private static final String DATABASE_PATH = "/data/data/你的主程序包路徑(如:com.szair.contact)/databases";
private static final int DATABASE_VERSION = 0;
private static final String DATABASE_NAME = "contact.db";
private static String outFileName = DATABASE_PATH + "/" + DATABASE_NAME;
try {
buildDatabase();//見下
} catch (Exception e) {
e.printStackTrace();
}
//SQLiteDatabase對象
SQLiteDatabase db=SQLiteDatabase.openDatabase(outFileName, null,SQLiteDatabase.NO_LOCALIZED_COLLATORS);
String t="SELECT 欄位名1,欄位名2 FROM employee WHERE **** ORDER BY ***";
Cursor c =db.rawQuery(t, null);
if(c.moveToFirst()){
for(int i=0;i
{
String zian1=c.getString(0);//欄位1的數據
String zian2=c.getString(1);//欄位1的數據
}
}
------------------------------------------------
//前面用到的buildDatabase方法
private void buildDatabase() throws Exception{
InputStream myInput = getResources().openRawResource(R.raw.sz_contact);
File file = new File(outFileName);
File dir = new File(DATABASE_PATH);
if (!dir.exists()) {
if (!dir.mkdir()) {
throw new Exception("創建失敗");
}
}
if (!file.exists()) {
try {
OutputStream myOutput = new FileOutputStream(outFileName);
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}
myOutput.close();
myInput.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
五、程序發布
按照以上方式,可以將外部建的SQLite資料庫成功的發布出來
Ⅱ eclipsecsv重置密碼
eclipsecsv重置密碼方法如下:
1.打開eclipsecsv的登錄頁面,點擊忘記密碼。
2.在彈出的窗口中輸入您的電子郵件地址後,就會收到一份包含重置密碼鏈接的電子郵件,點擊連接並輸入新密碼即可。
EclipseScada是一種基於Eclipse的開放式工業自動化軟體,用於處理CSV文件。
Ⅲ 如何使用eclipse編寫java程序讀取csv文件中
package ImportTestData;
import java.io.BufferedReader;
import java.io.FileReader;
public class Test {
public static void main(String[] args) {
try {
BufferedReader reader = new BufferedReader(new FileReader("a.csv"));//換成你的文件名
reader.readLine();//第一行信息,為標題信息,不用,如果需要,注釋掉
String line = null;
while((line=reader.readLine())!=null){
String item[] = line.split(",");//CSV格式文件為逗號分隔符文件,這里根據逗號切分
String last = item[item.length-1];//這就是你要的數據了
//int value = Integer.parseInt(last);//如果是數值,可以轉化為數值
System.out.println(last);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}