[QQ] Save textfile on SD - Android Q&A, Help & Troubleshooting

Hello devs.
I have a quick request for some skilled developer in Eclipse,how to save strings to SD card as a text file? I am noobie in Java development,so if someone is so friendly to provide me some source code of the solution,I'll be very grateful for it.
All I want is to create a simple program,which will save string from editbox to a file and it is appended to previous lines,already saved before. All other things I am able to do myself.
Please try out this program,that creates 'append.txt' file for imagination of my request.
Thanks all for your help in advance.
Here is my source in Delphi:
Code:
procedure TForm1.Button1Click(Sender: TObject);
var f:textfile;
const fi:string='append.txt';
begin
assignfile(f,fi);
if(fileexists(fi))then append(f) else rewrite(f);
writeln(f,edit1.text);
closefile(f);
end;

Related

Compile help with classes not in android.jar

Trying to compile some samples from the Android SDK.
I just took the AccelerometerPlay example, ran the command:
Code:
android update project -p . -t 1
which creates the Ant build file, then
Code:
ant release
which builds release APK files.
The problem is, if I add something like:
Code:
import android.util.Slog;
to the .java file, the build fails, claiming that it can't find the file (even though it exists in {sdk_path}/sources/android-15
I'm guessing that it looks for .class files inside {sdk_path}/platforms/android-15/android.jar , where android/util/Slog.class doesn't exist.
How do I get this build to work?
I've tried adding
Code:
<src path="${sdk.dir}/sources/android-15" />
under the <javac> task in {sdk_dir}/tools/ant/build.xml, but it seems to throw out more errors, whilst also appearing to try to compile every single .java file there.
I'm new to Java so really don't know what I'm doing - can anyone please point me in the correct direction?
Thanks.
Anyone have any idea?
If you're new to Java, you may want to give Eclipse a try. You won't have to mess around with Ant too much and it will help you with your syntax/imports.
From your description, it looks like you'll want to add the .jar file you mentioned to the 'classpath' attribute of the <javac> element in your ant XML file.
- chris
Thanks for the reply cttttt.
What .jar file are you referring to? android.jar? Because that doesn't have the classes as far as I know.
Eclipse gets me even less further - I can't seem to install the ADT plugin at all. On Eclipse 3.7.2, it throws the WST error, and when I try the solutions "that work", I get thrown network errors.
(so at least I can get a build actually going with Ant)

[Q] lockstyle coding

Hi, i'm wondering where i can read more about /system/media/lockstyle file structure and coding language. Yeah, i know that manifest is an XML file, but if we for example have this code:
Code:
<Var name="isreached_to_pressed" expression="1" const="true"/>
<Var name="lock_state_pressed" expression="eq(#unlocker_lock.state,1)+eq(#unlocker_call.state,1)+eq(#unlocker_mess.state,1)"/>
<Var name="lock_state_normal" expression="eq(#unlocker_lock.state,0)*eq(#unlocker_call.state,0)*eq(#unlocker_mess.state,0)"/>
<Var name="lockstate" expression="#unlocker_lock.state+#unlocker_call.state+#unlocker_mess.state"/>
<VariableCommand name="camera_show_ani_end" expression="ifelse(#leftToRight,#screen_width-abs(#touch_dist),abs(#touch_dist)-#screen_width)" const="true" condition="#camera_show_ani_con"/>
Where do i get more information about all this eq, abs, ifelse expression, and Var names like lock_state_pressed, lock_state_normal, camera_show_ani_end etc. Is there any guide out there, i wasn't able to find by myself.
Oh, one more thing.
Does the lockstyle file only describes the outlook of lock screen or does it also handle the actions like how to unblock (press, swap or tap)?

[Q] password.key decription

!!! Discussion is for educational purpose only !!!
As we know, Android stores Lockscreen's Pin and Password in data/system/password.key
In this file appears an alphanumeric string (probably an hex string which refer to other databases).
I've made a research, but I didn't find if it's possible to know the Lockscreen's password/pin starting with this file.
Any idea?
Can anyone try to explain how does it work?

How to perform baksmaling directly in an android device

Hello,
for the purpose of developing an antimalware for android, I need to have a baksamli representation of an APK.
the antimalware is itself an APK, that why I need the baksmaling operation to be performed in the device (i.e by the antimalware).
I asked the author of the baksmali tool (Issue #28)
he suggested me to use the dexlib2 library, but I don't think that I can get the smali representation of method calls (refer to the GitHub Issue).
After that I tried to execute the baksmali jar file directly in the device but I get a class not found error (sorry I can't provide the link to the stack overflow post, according to the policy of the forum I don't have the minimum post count)
Is there any other solution to get the smali of an APK ?(knowing that the solution will be executed in the Andriod device)
Thank you in advance
_Massy_ said:
Hello,
for the purpose of developing an antimalware for android, I need to have a baksamli representation of an APK.
the antimalware is itself an APK, that why I need the baksmaling operation to be performed in the device (i.e by the antimalware).
I asked the author of the baksmali tool (Issue #28)
he suggested me to use the dexlib2 library, but I don't think that I can get the smali representation of method calls (refer to the GitHub Issue).
After that I tried to execute the baksmali jar file directly in the device but I get a class not found error (sorry I can't provide the link to the stack overflow post, according to the policy of the forum I don't have the minimum post count)
Is there any other solution to get the smali of an APK ?(knowing that the solution will be executed in the Andriod device)
Thank you in advance
Click to expand...
Click to collapse
May be APK editor pro version help you..

how can i write to a file and read from it in android studio?

hi always use c and c++ but now i'm trying to create a game application with ndk
but it needs some java codes and i dont know java at all!!
i want to create a file
write a string in that file
then read that string again from that file?
can you help me? or show me a way to do that?!
mjs2001227 said:
write a string in that file
then read that string again from that file?
Click to expand...
Click to collapse
Write String to File in Java - TutorialKart
To write String to File in Java, there are many processes we can follow. Some of them are using FileUtils class of apache's commons.io library, Input Streams, etc.
www.tutorialkart.com
good luck!

Categories

Resources