Skip to content

Instantly share code, notes, and snippets.

@Matsushige
Created September 14, 2012 11:08
Show Gist options
  • Save Matsushige/3721334 to your computer and use it in GitHub Desktop.
Save Matsushige/3721334 to your computer and use it in GitHub Desktop.
CSVファイルダウンロード<データベース作成クラス>
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class Database extends SQLiteOpenHelper{
public Database(Context context){
super(context,"usersData.sqlite", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE users("
+"_id TEXT, type TEXT, id TEXT, name TEXT,"
+" code TEXT, time TEXT);");
ContentValues cv = new ContentValues();
cv.put("_id", "#");
cv.put("type","ic_type");
cv.put("id", "ic_id");
cv.put("name", "user_name");
cv.put("code", "code");
cv.put("time", "time");
// cv.put("level", 1);
db.insert("users", null, cv);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment