[Unity] SQLite가 안드로이드에 발표하면서 생긴 구덩이들.
*Player Setting에 있는 (안드로이드 옵션 중) Other Settings에 Optimization 아래에 있는 API Compatbility Level 선택이 있습니다.NET 2.0(그렇지 않으면 System.Data.dll 포장에 실패하는 상황이 발생할 수 있다. 왜 그런지 나도 모르겠다. 연구해 본 적이 없다. 외국의 대신에게서 알게 되었다...)
using UnityEngine;
using System.Collections;
using Mono.Data.Sqlite;
using UnityEngine.UI;
using System.IO;
public class AndroidLoadData : MonoBehaviour {
private Text name;
private Text score;
// Use this for initialization
void Start () {
name = GameObject.Find ("name").GetComponent ();
score = GameObject.Find ("score").GetComponent ();
ConnectionDataBase ();
}
public void ConnectionDataBase()
{
// 【 】
string sandboxPath = Application.persistentDataPath + "/Data0118.sqlite";
// 【 www 】 unity StreamingAssets
// APK ,
string downPath = "jar:file://" + Application.dataPath + "!/assets" + "/Data0118.sqlite";
// 【 】
// , StreamingAssets
if (!File.Exists(sandboxPath)) {
Debug.Log (" , Data0118.sqlite ");
// ,
// 1. sqlite , , ,
// 2. , ,
WWW www = new WWW (downPath);
// ,
while (!www.isDone) {
}
// www , sandboxPath
File.WriteAllBytes (sandboxPath, www.bytes);
}
//
string dataSandboxPath = "URI = file:" + Application.persistentDataPath + "/Data0118.sqlite";
SqliteConnection con = new SqliteConnection (dataSandboxPath);
//
con.Open ();
//
SqliteCommand com = con.CreateCommand ();
//
com.CommandText = "select name from MyTable where name = 'XiXi'";
//
name.text = com.ExecuteScalar ().ToString();
//
com.CommandText = "select score from MyTable where name = 'XiXi'";
//
score.text = com.ExecuteScalar ().ToString ();
//
con.Close ();
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
【Shader】유 니 티 를 사용 하여 수류 마그마 등 유동 효 과 를 생 성 합 니 다.텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.