Привет Всем, наконец, я нашел решение.Вот мой code.its отлично работает в устройстве Android.Надеюсь, это полезно.
string connection="";
//database creation
var filepath = string.Format("{0}/{1}", Application.persistentDataPath, "absdb.db");
try{
if (Application.platform != RuntimePlatform.Android) // Windows
{
connection = Application.dataPath + "/StreamingAssets/absdb.db";
if (!File.Exists(connection))
{
File.Create(connection);
}
}
else // Android
{
connection = filepath;
if (!File.Exists(filepath))
{
// if it doesn't ->
// open StreamingAssets directory and load the db ->
WWW loadDB = new WWW("jar:file://" + Application.dataPath + "!/assets/absdb.db"); // this is the path to your StreamingAssets in android
while (!loadDB.isDone) { } // CAREFUL here, for safety reasons you shouldn't let this while loop unattended, place a timer and error check
// then save to Application.persistentDataPath
File.WriteAllBytes(filepath, loadDB.bytes);
}
}
SQLiteConnection con = new SQLiteConnection(connection, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create);
SQLiteCommand CreateLifecmd = new SQLiteCommand(con);
CreateLifecmd.CommandText="CREATE TABLE Lifes( id INTEGER PRIMARY KEY AUTOINCREMENT,Lifes INTEGER not null); ";
CreateLifecmd.ExecuteNonQuery();
SQLiteCommand CreateLevelscmd = new SQLiteCommand(con);
CreateLevelscmd.CommandText = "CREATE TABLE Levels( id INTEGER PRIMARY KEY AUTOINCREMENT,UnlockLevels INTEGER not null); ";
CreateLevelscmd.ExecuteNonQuery();
SQLiteCommand insertLifecmd = new SQLiteCommand(con);
insertLifecmd.CommandText = "INSERT INTO Lifes (Lifes) Values (2)";
insertLifecmd.ExecuteNonQuery();
SQLiteCommand InsertLevelscmd = new SQLiteCommand(con);
InsertLevelscmd.CommandText = "INSERT INTO Levels (UnlockLevels) Values (1)";
InsertLevelscmd.ExecuteNonQuery();
}
catch
{
}