import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DictionaryOpenHelper extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 2;
private static final String DICTIONARY_TABLE_NAME = " user ";
private static final String DICTIONARY_TABLE_CREATE =
"CREATE TABLE " + DICTIONARY_TABLE_NAME + " (" +
"id" + " int, " +
"name" + " TEXT);";
DictionaryOpenHelper(Context context) {
super(context, "airib_database", null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
// db.execSQL(DICTIONARY_TABLE_CREATE);
}
@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2)
{
}
}
package fil.ted.test;
import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Environment;
import android.util.Log;
public class TestDAO
{
public static String getString(Activity activity)
{
// StringBuffer strBuf = new StringBuffer(Environment.getDataDirectory().toString());
// strBuf.append("/data/data/");
// strBuf.append("fil.ted.test");
//
// strBuf.append("/databases/");
// strBuf.append("air");
// String dbPath = strBuf.toString();
// SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
// db.execSQL("select id from airib");
DictionaryOpenHelper mDbHelper= new DictionaryOpenHelper(activity);
SQLiteDatabase db = mDbHelper.getReadableDatabase();
String [] strr ={"id","name"};
Cursor cursor = db.query("user", strr,
null, null, null, null, null);
//return cursor.toString();
String str = "start---";
if(cursor.moveToFirst()){
do{
str = str+cursor.getString(0)+cursor.getString(1)+""t";
}while(cursor.moveToNext());
}
return str;
}
/**
* @param args
*/
public static void main(String[] args)
{
System.out.println(12);
}
}