Hi! I’m trying to port my wear os app to tizen (due to switching from ticwatch pro to galaxy watch), but i have some problems. I have a db in my shared/res directory in visual studio project, and i’m trying to open it with sqlite (throught methods of System.Data.SQLite), without success, because i obtain a segmentation error when i create sqlite connection to db…is shared/res maybe read only directory, as in android? If yes, how can i solve the problem?
Here is the code:.
MainApps:
protected override void OnStart()
{
// Handle when your app starts
String db_path = "/opt/usr/apps/com.feduss.example.BusFinder.Tizen.Wearable/shared/res/CTM_BUS.sqlite";
SQLiteDatabase db = new SQLiteDatabase(db_path);
if (File.Exists(db_path))
{
Console.WriteLine("File exists...");
SQLiteCommand selectBusLines = new SQLiteCommand
("SELECT * from Routes");
DataTable res = db.GetDataTable(selectBusLines);
}
else
{
Console.WriteLine("File does not exist!");
}
}
SQLiteDatabase.cs:
public class SQLiteDatabase
{
private readonly string _dbConnection;
public SQLiteDatabase(string dataSource)
{
_dbConnection = string.Format("Data Source={0}", dataSource);
}
public DataTable GetDataTable(SQLiteCommand command)
{
if (command == null) throw new ArgumentNullException("command");
using (SQLiteConnection connection = new SQLiteConnection(_dbConnection))
{
connection.Open();
command.Connection = connection;
using (SQLiteDataReader reader = command.ExecuteReader())
{
DataTable result = new DataTable();
result.Load(reader);
return result;
}
}
}
public SQLiteCommand GetCommand(string sql)
{
if (string.IsNullOrEmpty(sql))
throw new ArgumentNullException("sql");
return new SQLiteCommand
{
CommandText = sql,
CommandType = CommandType.Text
};
}
public int ExecuteNonQuery(SQLiteCommand command)
{
if (command == null) throw new ArgumentNullException("command");
using (SQLiteConnection connection = new SQLiteConnection(_dbConnection))
{
connection.Open();
command.Connection = connection;
return command.ExecuteNonQuery();
}
}
}
SQLite c#
Hi! I’m trying to port my wear os app to tizen (due to switching from ticwatch pro to galaxy watch), but i have some problems. I have a db in my shared/res directory in visual studio project, and i’m trying to open it with sqlite (throught methods of System.Data.SQLite), without success, because i obtain a segmentation error when i create sqlite connection to db…is shared/res maybe read only directory, as in android? If yes, how can i solve the problem?
Here is the code:.
MainApps:
SQLiteDatabase.cs:
BY
16 Apr 2025
Tizen Studio
BY
04 Nov 2024
Tizen Studio
BY
02 Apr 2024
Tizen Studio