Я новичок в Xamarn и C #, и я попытался создать приложение с базой данных.И я пытаюсь выбрать каждую строку в таблице, и это сработало.Но когда я попытался вставить, ошибки не отображаются, но и я не вижу новую строку, добавленную в браузере SQLite .Кроме того, когда я попытался выбрать все строки, новый действительно появился :).
Я пытаюсь создать базу данных, в которой кто-то добавляет что-то, что он может увидеть больше, как магазин, если кто-то добавляет элемент, то каждый может его видеть.
Еще одна вещь, которую я всегда получаю, когдапопробуйте выбрать таблицу Unhandled Exception: Android.Database.Sqlite.SQLiteException: произошло введите описание изображения здесь
это мое соединение
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.Database.Sqlite;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using Java.Interop;
using Java.Lang;
using SQLite;
using Boolean = System.Boolean;
using Byte = System.Byte;
using SQLiteException = SQLite.SQLiteException;
namespace AppDatabase.Resources
{
public class DBdiagnoseX : SQLiteOpenHelper
{
private static readonly string DB_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
private static string DB_name = "Diagnose.db";
private static int VERSION = 1;
public Context context;
public DBdiagnoseX(Context context) :base(context, DB_name, null, VERSION)
{
this.context = context;
}
public string GetSqlPath()
{
return Path.Combine(DB_path, DB_name);
}
public override SQLiteDatabase WritableDatabase
{
get
{
return CreateSQLiteDB();
}
}
private SQLiteDatabase CreateSQLiteDB()
{
SQLiteDatabase sqliteDB=null;
string path = GetSqlPath();
Stream streamSQLite = null;
FileStream streamWriter = null;
Boolean IsSQLiteInit = false;
try
{
if (File.Exists(path))
IsSQLiteInit = true;
else
{
streamSQLite = context.Resources.OpenRawResource(Resource.Raw.Diagnose);
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{ }
return sqliteDB;
}