Friday, March 9, 2018

how to connect with android emulator sqlite db

1> install adb shell toos

brew cask install android-platform-tools

2> show devices
  adb devices                              
List of devices attached
emulator-5554 device

2> connect emulator run as root (otherwise ), and cd into database directory, Note if you don't run root you will have permission issues as follows

  adb -s emulator-5554 shell 


generic_x86:/ $ cd data/data/edu.gatech.seclass.sdpguessit/databases 
/system/bin/sh: cd: /data/data/edu.gatech.seclass.sdpguessit/databases: No such file or directory
run as root

  adb root -s emulator-5554 shell
restarting adbd as root
connect with emulator again

  adb -s emulator-5554 shell  

  cd data/data/com.myapp.seclass/databases 
   


3> run sqlite3
generic_x86:/data/data/com.myapp.seclass/databases # sqlite3 guessit3.db                                                     
SQLite version 3.19.4 2017-08-18 19:28:12
Enter ".help" for usage hints.
sqlite> .tables
Puzzle             android_metadata   statistics         userpuzzle       
Tournament         room_master_table  user             

sqlite> select * from userpuzzle;
2|0|1300|1
2|0|1300|2




show table schema

sqlite> .schema userpuzzle

CREATE TABLE `userpuzzle` (`userid` INTEGER NOT NULL, `puzzleid` INTEGER NOT NULL, `prize` INTEGER NOT NULL, `_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL);
CREATE INDEX `index_userpuzzle_userid` ON `userpuzzle` (`userid`);
CREATE INDEX `index_userpuzzle_puzzleid` ON `userpuzzle` (`puzzleid`);
CREATE INDEX `index_userpuzzle_prize` ON `userpuzzle` (`prize`);




Turn table column headers for queries

sqlite> .headers ON

sqlite> select * from userpuzzle;
userid|puzzleid|prize|_id
2|0|1000|3





No comments:

Post a Comment

java special for collection size, array size, and string size

Size: For Collections (eg: Map, List, etc ): usually it use collection.size(), eg         Map<Character, Integer> map ...