我是React-Native框架的新手,想知道AsyncStorage將數據存儲在設備上的位置。我知道它爲小數據存儲創建了一個序列化的字典,併爲大數據存儲創建了完整的文件,但我在哪裏可以找到這些文件?React Native的AsyncStorage在哪裏存儲數據?
0
A
回答
0
在的iOS,AsyncStorage由在單獨的文件中的串行化字典和較大的值存儲小的值 本地代碼的支持。在 的Android,AsyncStorage將使用兩種RocksDB或SQLite的依據是什麼 可用。
0
iOS上看起來它放入
static NSString *const RCTStorageDirectory = @"RCTAsyncLocalStorage_V1";
static NSString *const RCTManifestFileName = @"manifest.json";
static NSString *RCTGetStorageDirectory()
{
static NSString *storageDirectory = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
storageDirectory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
storageDirectory = [storageDirectory stringByAppendingPathComponent:RCTStorageDirectory];
});
return storageDirectory;
}
0
答案是在反應的本地代碼,由以前的答案的建議。移動設備上的實際位置將由NSDocumentDirectory確定。由於Apple在沙盒環境中運行您的應用程序,因此您只能訪問應用程序包中的目錄。看到這個SO問題/答案關於這個主題的更多細節:What is the documents directory (NSDocumentDirectory)?。
TL; DR:你可以把任何文件在此目錄中,但也有一些情況下,這可以被刪除,當用戶刪除您的應用程序,並重新安裝,或者在操作系統升級等。目錄本身就是捆綁中的〜/ Documents,顯然儘管我不確定爲什麼這很重要。
中的相關代碼反應母語:
static NSString *RCTGetStorageDirectory()
{
static NSString *storageDirectory = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
#if TARGET_OS_TV
storageDirectory = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject;
#else
storageDirectory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
#endif
storageDirectory = [storageDirectory stringByAppendingPathComponent:RCTStorageDirectory];
});
return storageDirectory;
}
相關問題
- 1. 在移動應用上,realm React-Native存儲數據在哪裏?
- 2. 無法將值存儲在React Native的asyncStorage中
- 3. AsyncStorage使用React Native保存狀態
- 4. 什麼是AsyncStorage(react-native)?
- 5. React Native:從AsyncStorage加載值
- 6. React-Native更新AsyncStorage項目
- 7. React Native - 如何查看AsyncStorage中存儲的內容?
- 8. React Native在導出之前等待AsyncStorage
- 9. react-native:如何在rocksdb中使用asyncstorage?
- 10. 在哪裏存儲數據?
- 11. 數據存儲在哪裏?
- 12. React Native AsyncStorage在渲染後獲取數據
- 13. React Native中的AsyncStorage有多大?
- 14. React Native中的require('styles')在哪裏
- 15. React Native的AsyncStorage可能出現哪些故障?
- 16. React Native AsyncStorage:從Promise對象訪問值
- 17. 我的BigQuery數據存儲在哪裏?
- 18. ByteArray的數據存儲在哪裏?
- 19. 在哪裏存儲我的數據?
- 20. 在哪裏存儲jquery的數據?
- 21. EXCEL Sheet的數據在哪裏存儲?
- 22. 存儲MongoDB的數據在哪裏SailsJS
- 23. ProfileBase.Save()存儲我的數據在哪裏?
- 24. UDP存儲的數據在哪裏?
- 25. cck「數值」數據存儲在哪裏?
- 26. 使用React Native AsyncStorage存儲列表:許多密鑰還是一個?
- 27. 通過應用程序更新在App Store/Google Play中使用React-Native AsyncStorage存儲數據
- 28. Redis在哪裏存儲數據
- 29. 常量數據應存儲在哪裏?
- 30. 存儲視圖數據在哪裏?
這將有助於找出確切的文件存儲。我想我們都已經閱讀了文檔。在我的模擬器上,這些文件似乎位於'/ data/data/com.my.app /'下 – hcvst