getReal method
Future
getReal(
- dynamic dbName
)
Implementation
Future<dynamic> getReal(dbName) async {
dynamic intValue;
List<Map<String, dynamic>> allRows = [{}];
Directory documentsDirectory = await getApplicationDocumentsDirectory();
String path = join(documentsDirectory.path, "$dbName.db");
Database _database = await openDatabase(path, version: _databaseVersion,
onCreate: (Database db, int version) async {
await db.execute(
'CREATE TABLE ${dbName}1 (${dbName}_key INTEGER, $dbName REAL)');
});
Database db = _database;
var getValue;
getValue = Sqflite.firstIntValue(
await db.rawQuery('SELECT COUNT(*) FROM ${dbName}1'));
try {
allRows = await db.query(dbName + '1');
intValue = allRows[getValue - 1][dbName];
print("$dbName value is $intValue");
return intValue;
} catch (exception) {
print("no data was found in $dbName");
return 0;
}
}