【Android】建立資料庫的小工具

來源:互聯網
上載者:User

標籤:android   des   style   http   java   color   

功能

方便將文本表格式資料匯入到資料庫中去,從而避免手動去添加一條條的類比資料。

使用方法

將文本表格放在恰當的位置,類似於:

檔案位置:/assets/mock_table.csv:檔案內容:name#string, age#int, course#stringxesam_1, 1, desc_Axesam_2, 2, desc_Bxesam_3, 3, desc_Cxesam_4, 4, desc_Dxesam_5, 5, desc_Exesam_6, 6, desc_Fxesam_7, 7, desc_G

然後在Application或者Activity或者其他合適的地方調用下面的方法即可:

MockSQLiteInflater sqLiteInflater = new MockSQLiteInflater(); SQLiteDatabase db2 = sqLiteInflater            .addTable(MockTable.newAssetTable("mock_table.csv",aliasTableName))             .reInflateTo(this, dbName);

上面的調用會建立一個名為dbName的資料庫,然後講mock_table.csv檔案中的內容匯入到aliasTableName資料庫表中

demo

其他方法已經demo參見https://github.com/xesam/MockSQLiteInflater

Android分享 Q群:315658668


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.