Storing Key-Value Data On Disk

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€87.82
List Price:  €122.96
You save:  €35.13
£75.16
List Price:  £105.22
You save:  £30.06
CA$138.43
List Price:  CA$193.81
You save:  CA$55.37
A$156.59
List Price:  A$219.24
You save:  A$62.64
S$131.16
List Price:  S$183.63
You save:  S$52.46
HK$775.77
List Price:  HK$1,086.11
You save:  HK$310.34
CHF 82.51
List Price:  CHF 115.51
You save:  CHF 33
NOK kr1,042.39
List Price:  NOK kr1,459.39
You save:  NOK kr417
DKK kr655.69
List Price:  DKK kr918
You save:  DKK kr262.30
NZ$167.31
List Price:  NZ$234.24
You save:  NZ$66.93
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳12,147.63
List Price:  ৳17,007.17
You save:  ৳4,859.53
₹8,526.15
List Price:  ₹11,936.95
You save:  ₹3,410.80
RM437.25
List Price:  RM612.17
You save:  RM174.92
₦161,582.84
List Price:  ₦226,222.44
You save:  ₦64,639.60
₨28,083.99
List Price:  ₨39,318.71
You save:  ₨11,234.71
฿3,343.46
List Price:  ฿4,680.98
You save:  ฿1,337.52
₺3,831.60
List Price:  ₺5,364.40
You save:  ₺1,532.79
B$572.90
List Price:  B$802.08
You save:  B$229.18
R1,870.82
List Price:  R2,619.22
You save:  R748.40
Лв171.98
List Price:  Лв240.78
You save:  Лв68.80
₩143,528.93
List Price:  ₩200,946.25
You save:  ₩57,417.31
₪364.89
List Price:  ₪510.86
You save:  ₪145.97
₱5,649.88
List Price:  ₱7,910.06
You save:  ₱2,260.18
¥14,243.72
List Price:  ¥19,941.78
You save:  ¥5,698.06
MX$1,958.93
List Price:  MX$2,742.58
You save:  MX$783.65
QR364.07
List Price:  QR509.71
You save:  QR145.64
P1,365.84
List Price:  P1,912.23
You save:  P546.39
KSh12,938.70
List Price:  KSh18,114.70
You save:  KSh5,176
E£5,095.17
List Price:  E£7,133.44
You save:  E£2,038.27
ብር13,416.63
List Price:  ብር18,783.83
You save:  ብር5,367.19
Kz91,190.88
List Price:  Kz127,670.88
You save:  Kz36,480
CLP$94,266.88
List Price:  CLP$131,977.40
You save:  CLP$37,710.52
CN¥728.62
List Price:  CN¥1,020.10
You save:  CN¥291.48
RD$5,931.15
List Price:  RD$8,303.85
You save:  RD$2,372.70
DA13,230.85
List Price:  DA18,523.73
You save:  DA5,292.87
FJ$226.02
List Price:  FJ$316.44
You save:  FJ$90.41
Q770.12
List Price:  Q1,078.20
You save:  Q308.07
GY$20,916.83
List Price:  GY$29,284.40
You save:  GY$8,367.57
ISK kr12,726.72
List Price:  ISK kr17,817.92
You save:  ISK kr5,091.20
DH925.43
List Price:  DH1,295.64
You save:  DH370.21
L1,727.39
List Price:  L2,418.42
You save:  L691.02
ден5,403.80
List Price:  ден7,565.54
You save:  ден2,161.73
MOP$799.06
List Price:  MOP$1,118.72
You save:  MOP$319.65
N$1,856.77
List Price:  N$2,599.55
You save:  N$742.78
C$3,679.18
List Price:  C$5,151.01
You save:  C$1,471.82
रु13,655.87
List Price:  रु19,118.77
You save:  रु5,462.89
S/369.72
List Price:  S/517.62
You save:  S/147.90
K407.72
List Price:  K570.82
You save:  K163.10
SAR375.06
List Price:  SAR525.10
You save:  SAR150.04
ZK2,836.90
List Price:  ZK3,971.77
You save:  ZK1,134.87
L437.14
List Price:  L612.02
You save:  L174.87
Kč2,196.89
List Price:  Kč3,075.74
You save:  Kč878.84
Ft35,797.65
List Price:  Ft50,118.14
You save:  Ft14,320.49
SEK kr961.88
List Price:  SEK kr1,346.67
You save:  SEK kr384.79
ARS$116,335.31
List Price:  ARS$162,874.09
You save:  ARS$46,538.78
Bs690.85
List Price:  Bs967.22
You save:  Bs276.37
COP$430,007.65
List Price:  COP$602,027.91
You save:  COP$172,020.26
₡50,277.57
List Price:  ₡70,390.61
You save:  ₡20,113.04
L2,591.91
List Price:  L3,628.78
You save:  L1,036.87
₲799,756.92
List Price:  ₲1,119,691.68
You save:  ₲319,934.76
$U4,193.03
List Price:  $U5,870.41
You save:  $U1,677.38
zł375.98
List Price:  zł526.39
You save:  zł150.40
Already have an account? Log In

Transcript

Hello, in this video, I am going to show you how to store key value pairs, you know internally on your device for local usage. So I've already got the code set up, I'm going to run through this with you, what I want you to do is make sure you've gone through the previous video we shouldn't be reading and writing to files. This is essentially an extension of that there are a few modifications to it, which you can check on the source code and I'm going to be covering that one. So basically, we're going to do is go from the million by two files code that we did in that video and adapted into this one. So the first thing that you want to do, go to the pub spec dot yamo and add the shared preferences. dependency Lake version as a Christmas video is 0.5 point one, two and unusual.

You can get the latest version by going to pub dartlang.org forces packages to share Here we go go to installing. And if we literally just copy down the do floater, get We don't even need to do it, you can just click date on it top to command. And okay, then you need to actually do the import, you don't need to do all the other crazy imports that you did for reading and writing to files. Okay, so what else have we got in here. So we've got a, you know, a few methods. So this one, initially just load the cat as you can see, this is you know, a lot simpler than the reading and writing files code.

So you have your load counter, you create a shared preferences. And this will, you know, be dynamic, whether it's on Android or iOS, your handle all of that in the back end, and you can reset state, which is just normal stuff. Then to actually get something just do press, get int and then name up. So this is the key, then you know this will return the actual value. And then if there isn't something then you just put zero there. And again, when you're incrementing it you go, you know, open it up, you do press dot get int, and status anything we are getting the value that you add to the key counter, adding one and then to setting just depressed offsetting the name of the key, the value and that is and obviously there is a button that increments but as you can see, it is extremely simple to utilize shared preferences only to have a goat that they have any questions, feel free to drop me a message.

And as usual, I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.