私はxamarinを使用しています。私は現在カスタムアレイアダプタを使用していますが、私の専門家です。私のシステムにはデータベースが含まれていると言われましたので、jsonを見つけるまで検索を続けましたが、誰かがSQliteを使用するとデータをより速く取り出すことができると私に言いました。だから、私はすでにSQLite Manager(firefox plugin)を使って自分自身で事前に作成したSQLiteデータベースファイルを作成しました。私はこのlinkに従って、自分のSQLiteデータベースファイルを使用しています。私は次に何をすべきかわかりません。ほぼ2時間を探していますが、役に立つ例は見つかりませんでした。申し訳ありません。誰も私に有用なリンクを与えることができますか?私がこれまで持っているものどのように自分のsqliteファイルからlistviewを設定するには?
:
public class DBOpenHelper:SQLiteOpenHelper
{
private static string DB_PATH = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
private static string DB_NAME = "akyatpinas.db";
private static int VERSION = 1;
private Context context;
public DBOpenHelper(Context context) : base(context, DB_NAME, null, VERSION)
{
this.context = context;
}
private string GetSQLiteDBPath()
{
return Path.Combine(DB_PATH, DB_NAME);
}
public override SQLiteDatabase WritableDatabase
{
get { return CreateSQLiteDB(); }
}
private SQLiteDatabase CreateSQLiteDB()
{
SQLiteDatabase sqliteDB =null;
string path = GetSQLiteDBPath();
Stream streamSQLite = null;
FileStream streamWriter = null;
Boolean isSQLiteInit = false;
try
{
if (File.Exists(path))
isSQLiteInit = true;
else
{
streamSQLite = context.Resources.OpenRawResource(Resource.Raw.akyatpinas);
streamWriter = new FileStream(path,FileMode.OpenOrCreate,FileAccess.Write);
if (streamSQLite != null && streamWriter != null)
{
if (CopySQLiteDB(streamSQLite, streamWriter))
isSQLiteInit = true;
}
}
if (isSQLiteInit)
sqliteDB = SQLiteDatabase.OpenDatabase(path, null, DatabaseOpenFlags.OpenReadonly);
}
catch
{
// ignored
}
return sqliteDB;
}
private bool CopySQLiteDB(Stream readStream, FileStream writeStream)
{
bool isSuccess = false;
int length = 256;
Byte[] buffer = new Byte[length];
try
{
// write the required bytes
int bytesRead = readStream.Read(buffer, 0, length);
while (bytesRead > 0)
{
writeStream.Write(buffer, 0, bytesRead);
bytesRead = readStream.Read(buffer, 0, length);
}
isSuccess = true;
}
catch
{
//ignore
}
finally
{
readStream.Close();
writeStream.Close();
}
return isSuccess;
}
public override void OnCreate(SQLiteDatabase db)
{
}
public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
throw new NotImplementedException();
}
}
はい私は作成しましたが、私の問題はどのようにそれを操作する。私の記事を編集しました – chlara