How to read a raw text file from SD card?
This is not the complete solution, but you get the idea.
int updateVersionCode = info.versionCode;
try {
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard, "version.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
if((line = br.readLine()) != null){
updateVersionCode = Integer.parseInt(line);
}
br.close();
}catch (Exception e) {
//Handle errors!
e.printStackTrace();
}
if (info.versionCode < updateVersionCode) {
//The local version is minor, so updates are avaliable...
}
How to read a text file from SD card in Android device through command prompt?
You don't need to pull the file.adb
provides shell acces, so you can do a cat
:
adb shell cat /sdcard/D_Permission/foo.txt
If the file does not exist though, you'll still get "does not exists" error of course, which is normal.
Related Topics
How to Get the Absolute Coordinates of a View
How to Use Disk Caching in Picasso
How to Animate Recyclerview Items When They Appear
Android Update Activity UI from Service
Android- Going Back to Previous Activity with Different Intent Value
Changing Background Color of Listview Items on Android
How to Fire Onlistitemclick in Listactivity with Buttons in List
How to Change Language of App When User Selects Language
Using Both Front and Back Cameras Simultaneously Android
Android: Create Spinner Programmatically from Array
Determine If Android App Is Being Used For the First Time
Runtimeexception: Your Content Must Have a Listview Whose Id Attribute Is 'Android.R.Id.List'
Android: How to Check If a View Inside of Scrollview Is Visible
How to Use Algolia Query in Firestorerecycleroptions
Android: Progressdialog.Show() Crashes with Getapplicationcontext
Android Room - Simple Select Query - Cannot Access Database on the Main Thread
How to Delete an Sms from the Inbox in Android Programmatically