I have written a file author for my Android application. This is to work on the Galaxy Tab, so my minimum SDK version should be at least 4, so it will fill the screen. I originally started with SdkVersion = 2 and at that point my file author worked perfectly. Changing the SdkVersion from 4 to the problem of presenting my file author are no longer working! This application is running fine, but a file is not created.
My .java file looks like this:
Public category Hello Android enhances activity {/ ** is called when activity is created first. * / @Override Public Zero onCreate (bundled savedInstanceState) {super.onCreate (savedInstanceState); TextView TV = new textview (this); Tv.setText ("Hello, Android"); SetContentView (R.layout.main); // To define NAP card button 1 OG SLNTN LISON P.O. DENNE Button Button 1 = (Find Button) VVBIID (RBTNClick); Button1.setOnClickListener (btnListener); // Define Encapsulate Cundette Button 2 and SLNTN Lister PA ¥ DENNE Button Button 2 = (Find Button) VVIBID (RID.btnclick2); Button2.setOnClickListener (btnListener2); } // N Bhilabil AP Typin 'Long' Declares Lars Og Caldas TID 1 Public Long 1; Private OnClickListener btnListener = New OnClickListener () {Public Zero onClick (see v) {// NÃ ¥ r der klikkes PA ¥ Button1 Gemmes et cadence i variablen tid1 Time1 = System.currentTimeMillis (); }}; // N Bhilabel App Typin 'Long' Declares Lars Og Caldas TID 2. Public long time 2; // N Bhilabel F Typ 'String' Declar Lals and Written: Public String String 1 = "Time:"; Private OnClickListener btnListener2 = New OnClickListener () {Public Zero onClick (see v) {// NÃ ¥ r der klikkes PA ¥ Button2 Gemmes et cadence variablen tid2 Time2 = System.currentTimeMillis (); // then try "file.txt" {file file = new file (environment. Gatestile store's directory ("," file.txt ") for the opacity and file; File.createNewFile (); BufferedWriter Author = New BufferedWriter (New FileWriter (file, true)); // string 1 and trid2-tid1 skids til file from Tid2-tid1 to giver itself to the right of the traktor to the right of the millisecond. Author. Written (string 1 + "\ t" + (time 2-time 1)); Writer.newLine (); Writer.flush (); Writer.close (); } Hold (IOException e) {e.printStackTrace (); }}};
utf-8 ">
& lt; app android: icon = "@drawable / icon" Android: label = "@ string / app_name"> Android: name = ". HelloAndroid "android: label =" @ string / app_name "> & lt; intent-filter & gt; & lt; action android: name =" android.intent.action.MAIN "/> & lt; category android : Name = "android.intent.category.LAUNCHER" /> & lt; / intent-filter & gt; & lt; / activity & gt; & lt; / application & gt;
Why does not my file author work with the minimum SDK version> 2? Do I have to create a new filelighter? Or what to do?
Sorry for the dirty code, I am quite new to programming :)
will give you 2 new Notifications need to be added:
Use of Android - permission: name = "android.permission.WRITE_EXTERNAL_STORAGE" /> & lt; use-permission Android: name = "android.permission. READ_EXTERNAL_STORAGE "/> These permissions were not added until API level 4, so they get anything for free below. < / Html>
Comments
Post a Comment